Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2008
    Location
    India
    Posts
    40

    Unanswered: Record # for the rows displayed in DB2 query

    Hi,
    I need to write a query which selects some columns from a table with a
    Serial number being displayed along with the other data from the table

    For eg:
    SNO Doc#
    1 xxxyy
    2 abcd
    3 xyz


    This SNO should be made to increment in the query itself.
    Its like a numbering for the rows displayed.

  2. #2
    Join Date
    Jul 2006
    Location
    Pune , India
    Posts
    433
    Olap functions:
    row_number() over()
    Rahul Singh
    Certified DB2 9 DBA / Application Developer

  3. #3
    Join Date
    Oct 2008
    Location
    India
    Posts
    40
    It is displaying the message
    "The function ROW_NUMBER() not found"
    Any other solution

  4. #4
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    What is the Version of DB2 you are using and what is the operating system?

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by Neena John
    It is displaying the message
    "The function ROW_NUMBER() not found"
    Any other solution
    The post above did not provide the exact syntax you need to use for the OLAP function. Please check the SQL Reference manual to see if it is supported on your version of DB2, and to see exactly how to use the OLAP function.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  6. #6
    Join Date
    Oct 2008
    Location
    India
    Posts
    40
    I am using DB2 verson 7

  7. #7
    Join Date
    Oct 2008
    Location
    India
    Posts
    40
    I am using DB2 verson 7

  8. #8
    Join Date
    Aug 2009
    Posts
    8
    $ db2 "select ROW_NUMBER() over() Row_Count, DEPTNUMB, DEPTNAME from org"

    ROW_COUNT DEPTNUMB DEPTNAME
    -------------------- -------- --------------
    1 10 Head Office
    2 15 New England
    3 20 Mid Atlantic
    4 38 South Atlantic
    5 42 Great Lakes
    6 51 Plains
    7 66 Pacific
    8 84 Mountain

    8 record(s) selected.

  9. #9
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by Neena John
    I am using DB2 verson 7
    You did not state whether this is DB2 for z/OS or DB2 for Linux, UNIX, and Windows. Check the SQL Reference for your product to see if the row-number function is supported.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

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