Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2012
    Posts
    3

    Unanswered: Basic SQL response for select in SQL

    Hi Folks,

    I am pretty new to DB2 SQL.

    The below SQL statement is simple enough to look up the count from an event able.

    ---> db2 "select count (*) from rep.event_table"

    The issue is the display I get in cmd line output

    1
    ------------
    0

    1 record(s) selected
    .

    Any idea how I can just print 1 instead of the those extra dashes?

    Thanks

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    "1" is the column heading (for column 1 in your select list) printed by the Command Line Processor, which is separate from the DB2 engine.

    Not sure what you want, but try the following options to see if you like them any better:

    db2 -x "select count (*) from rep.event_table"

    db2 "select count (*) as COUNT from rep.event_table"
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Jun 2012
    Posts
    3
    Thanks Marcus,

    I am trying to get the count into a variable and compare it against an defined number/count.

    I will try your suggestions.

    Thanks

  4. #4
    Join Date
    Jun 2012
    Posts
    3
    Thanks Marcus,

    The first option worked and I just got the count.

    Ta

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •