Results 1 to 5 of 5

Thread: Rownum

  1. #1
    Join Date
    Jun 2004
    Location
    Far away from heaven
    Posts
    194

    Unanswered: Rownum

    Hi folks,
    SELECT * FROM mytable
    100 rows returned.
    Can i get a rownum column for each record; i.e. if 100 records returned; rownum order 1,2,3.....100 along with the each record position.
    is it possible without using cursor?


    Howdy!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002

  3. #3
    Join Date
    Nov 2004
    Posts
    30
    Assuming that you have atleast one primary key or at least a unique constraint:

    Select Count(RowTable.UniqueField) as RowNumber, Mytable.Fields
    from Mytable
    inner join Mytable RowTable on Mytable.UniqueField >= RowTable.UniqueField

    Even I had the Same problem. Thanks To Blindman for his help regarding the query.

  4. #4
    Join Date
    Jun 2004
    Location
    Far away from heaven
    Posts
    194
    Thanx to r937 and blindman!

  5. #5
    Join Date
    Feb 2004
    Posts
    492
    Quote Originally Posted by sudheesh_k_s
    Assuming that you have atleast one primary key or at least a unique constraint
    Also: NULL values won't be counted. In the other thread the values were used as columnnames, so NULL is quite unlikely. Not sure about myTable.

Posting Permissions

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