Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Rownum
Hi again,
Thanks to all who responded.
However, I've have tried several of these and they all work fine, as long as there is no ORDER BY clause. In order for the results to be returned correctly, the ORDER BY clause would need to be in the main query and the sub query.
As soon as I try to do that, I get an error, e.g.
1 select id, surname, first_name from 2 (select id, surname, first_name, rownum rn 3 from telephone_directory where rownum < 15 4 order by first_name) 5 where rn > 7 6* order by first_name SQL> / order by first_name) * ERROR at line 4: ORA-00907: missing right parenthesis
If I miss off the second ORDER BY, the results are wrong.
The application is such that the web user selects the order that the results are returned, and the SQL statement is built dynamically in the JavaScript.
Sue