Re: problem with ROWNUM

From: Dmitry E. Loginov <lde_at_mpsb.moris.ru>
Date: Wed, 18 Apr 2001 16:35:45 +0000 (UTC)
Message-ID: <7851.010418_at_mpsb.moris.ru>


Gabriel,

GB> OK. I got more questions! :)

GB> I have a very complicated query that have this format: in Oracle 8 try

select * from (
 select b1.blah, b2.blah
  from blah b1, blah b2, blah b3
  where
    a complicated predicate here
  order by attribute DESC;
)
where rownum<=:maxRows

GB> select blah blah
GB> from blah, blah, blah
GB> where
GB>    (a complicated predicate here) AND (ROWNUM <= :maxRows)
GB> order by attribute DESC;

GB> The thing is that SQL stops when it reaches the maxRows rows, and THEN it sorts the rows. I got this problem since I need to return the rows ordered by date in descending order, but the query GB> doesn't return the LAST date in the tables, because of the problem with ROWNUM.

GB> What I need to do is get all the rows sorted, and THEN select the first maxRows.

GB> How do I do that?

GB> Regards,
GB> Gabriel

GB> Get 250 color business cards for FREE! GB> http://businesscards.lycos.com/vp/fastpath/

 Dmitry...                            mailto:lde_at_mpsb.moris.ru



-- 
Posted from ns.mpsb.moris.ru [213.242.27.84] 
via Mailgate.ORG Server - http://www.Mailgate.ORG
Received on Wed Apr 18 2001 - 18:35:45 CEST

Original text of this message