problem with ROWNUM

From: Gabriel Belingueres <belingueres_at_lycos.com>
Date: Wed, 18 Apr 2001 16:22:05 +0000 (UTC)
Message-ID: <HNPMDALJPECODAAA_at_mailcity.com>


[Quoted] OK. I got more questions! :)

I have a very complicated query that have this format:

select blah blah
from blah, blah, blah
where

   (a complicated predicate here) AND (ROWNUM <= :maxRows) order by attribute DESC;

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 doesn't return the LAST date in the tables, because of the problem with ROWNUM.

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

How do I do that?

Regards,
Gabriel

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

-- 
Posted from fes-qout.whowhere.com [209.185.123.96] 
via Mailgate.ORG Server - http://www.Mailgate.ORG
Received on Wed Apr 18 2001 - 18:22:05 CEST

Original text of this message