Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Nested queries with an order by clause
I need to select everything from a huge table ( 1.5 million records )
( its a book database, shhhh, don't tell anybody )
Since I'll be displaying all of these a few pages at a time. I want
to be able to get just the page I want out of the whole table. The
problem is that the whole list has to be ordered by title.
This is what I tried to do:
select title,isbn,listprice
from
(
select title,isbn,listprice,inner_rownum
from
(
select title,isbn,listprice,rownum as inner_rownum
from book
order by title /*hint: this ones the stinker*/
)
where inner_rownum > BEGING_PAGE
)
where inner_rownum < END_PAGE
The proble is that oracle ( or sql in genreal ? ) dosent like that "order by" in the inner query. Any suggestions? Remember the requirement is to get a sub range of the whole table ordered by title. Just moving the "order by" clause to the outside dosent work since each page will be ordered by title, but the list as a whole will not be ordered properly.
--
Marvin
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Nov 05 1999 - 13:37:58 CST