Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Mumbai
    Posts
    19

    Smile Unanswered: How to determine ROWCOUNT in DB2

    I have to use one query in DB2 like

    Select NAME from TAB_NAME where ROWCOUNT=1;

    In Oracle we have function ROWCOUNT.In DB2 what is the similar function ?

  2. #2
    Join Date
    Oct 2001
    Location
    Bangalore
    Posts
    186
    Here's the way:

    SELECT * FROM (SELECT name, rownumber() OVER
    (ORDER BY pkcol)
    AS rn FROM TABLENAME)
    AS tr WHERE rn BETWEEN 1 and 10

    Modify this as per your need..

    Cheers,
    Prashant

  3. #3
    Join Date
    Dec 2002
    Location
    Mumbai
    Posts
    19
    Thanks for ur reply..it works...
    if i want to write a query like this what is the solution....

    update TAB_NAME set NAME='xyx' where ROWCOUNT=1



    Originally posted by dahalkar_p
    Here's the way:

    SELECT * FROM (SELECT name, rownumber() OVER
    (ORDER BY pkcol)
    AS rn FROM TABLENAME)
    AS tr WHERE rn BETWEEN 1 and 10

    Modify this as per your need..

    Cheers,

  4. #4
    Join Date
    Oct 2001
    Location
    Bangalore
    Posts
    186
    Hi,

    We can do like this:

    update TAB_NAME set NAME='xyx' where name = (SELECT name FROM (SELECT name, rownumber() OVER
    (ORDER BY pkcol)
    AS rn FROM TAB_NAME)
    AS tr WHERE rn=1)

    Here pkcol is the primary key or any unique column.
    Cheers,
    Prashant

Posting Permissions

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