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 -> Re: selecting _only_ the latest ten items

Re: selecting _only_ the latest ten items

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Tue, 07 Sep 1999 18:32:53 +0800
Message-ID: <37D4E9D5.2157@yahoo.com>


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
--



Connor McDonald
"These views mine, no-one elses etc etc" connor_mcdonald_at_yahoo.com

"Some days you're the pigeon, and some days you're the statue." Received on Tue Sep 07 1999 - 05:32:53 CDT

Original text of this message

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