Home » RDBMS Server » Server Administration » Re: serial number in SQL reports
Re: serial number in SQL reports [message #373598] Wed, 25 April 2001 13:05
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
The rownum is assigned before the sorting is done. Try changing the "order by".
Bellow is the natural order of the data in my tab.
1
9
13
999
6

This different results are:
-- Rownum IS NOT consecutive from 1
select abc.*, rownum from abc order by a desc;

999 4
13 3
9 2
6 5
1 1

-- Rownum IS consecutive from 1
select qry.*, rownum
from (select * from abc order by a desc) qry;
999 1
13 2
9 3
6 4
1 5
Previous Topic: Re: serial number in SQL reports
Next Topic: sql query for converting a long data type value into a integer data value
Goto Forum:
  


Current Time: Sat Jun 29 00:28:53 CDT 2024