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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to get the first 10 records(with order by)?

Re: How to get the first 10 records(with order by)?

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Mon, 4 Oct 1999 14:55:19 +0200
Message-ID: <7ta858$1ef$1@oceanite.cybercable.fr>


Roland
That doesn't work because row number is given *before* the order by. So your query gives the 10 first orders and then orders them by saledate.

If you want the 10 first orders that is those which saledate have less than 10 lower saledates, you can use something like:

select * from orders a
where 10 <= (select count(saledate)

             from orders b where b.saledate <= a.saledate) order by saledate
/

--
Regards

Michel

Roland Schaar <rschaar_at_gosch.com> a écrit dans le message : 37F88897.CB922F24_at_gosch.com...
> ...
> where rownum <= 10
>
> Roland Schaar
> Gosch Consulting GmbH
>
> wy_at_fudan.edu wrote:
>
> > How to get the first 10 records in a sql(with order by)?
> > In sqlserver7.0,
> > I can use "select first 10 * from orders order by saledate" to get the
> > first 10 records,and how to do this in oracle?
> >
> > any suggestions are helpful!
> > thanks in advance!
> >
> > wangyang.
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
Received on Mon Oct 04 1999 - 07:55:19 CDT

Original text of this message

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