Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: selecting _only_ the latest ten items
Jeff Smith wrote:
>
> Pardon me for butting in, but didn't I read somewhere that ROWNUM was
> assigned prior to the order by?
>
> Jeff
>
> Timo Biesenbach wrote:
> >
> > Hi,
> >
> > If you're using Oracle, you may use the rownum pseudocolumn to filter
> > your 10 latest rows out :
> >
> > select * from (select * from news order by date desc)
> > where rownum between 0 and 10;
> >
> > -timo
> >
> > > What's the best way of selecting, say, the latest 10 news stories from a
> > > DB. Do I have to select all the items ordered by date, but just show the
> > [...]
> > > are displayed, etc.
> > >
> > > TIA,
> > > - Kev
> >
> > --
> > +---+---+-+-+-+-+
> > | | |-+-+-+-+ Fraunhofer-Institut fuer Graphische Datenverarbeitung
> > +---+---+-+-+-+-+ Fraunhofer-Institute for Computer Graphics
> > | | |-+-+-+-+ Abteilung / Department : Document Imaging
> > +---+---+-+-+-+-+
> > | __ _ | Timo Biesenbach
> > | ! ! _ ! \ | Rundeturmstr. 6 phone ++49 6151 155 578
> > | ! !__! !_/ | 64283 Darmstadt fax ++49 6151 155 299
> > +---------------+ Germany email timo.biesenbach_at_igd.fhg.de
The solution mentioned will only work in 8i (since there is an order by in the inline select ) and thus overcomes the classic "rownum assigned before..."...
HTH
--
"Some days you're the pigeon, and some days you're the statue." Received on Tue Sep 07 1999 - 05:32:53 CDT
![]() |
![]() |