Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Nested queries with an order by clause

Nested queries with an order by clause

From: Marvin <marteaga76_at_my-deja.com>
Date: Fri, 05 Nov 1999 19:37:58 GMT
Message-ID: <7vvbmh$4v0$1@nnrp1.deja.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US