Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Order by , Rownum problem 1

Status
Not open for further replies.

PeteC1000

Programmer
Sep 23, 2005
1
0
0
GB

Hi , I am trying to select the first 200 rows from a table with the primary key in sequential order.

Example
Select primary_key#
from table_name
where rownum <=200
order by 1

However, I have realised that rownum is dealt with first by oracle and then the order by clause distorts the result set.

Any help much appreciated on how I could accomplish this ?
I am using Oracle 9.2 but ideally this needs to work with Oracle 7.36 as well.


 
Dima's code should work on oracle 9.2 but won't work on version 7, as you can't put an order by on an inline view in version 7. I know I tried it the other day. :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top