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: Mehul Zaveri <mehulzaveri_at_hotmail.com>
Date: Tue, 7 Sep 1999 18:54:24 +0400
Message-ID: <7r38jp$fnp1@news.emirates.net.ae>


Try out this query...
-- earliest two
select * from toppers a
where 2 > (select count(*) from toppers b

                   where b.dt < a.dt );
-- latest two
select * from toppers a
where 2 > (select count(*) from toppers b
                   where b.dt > a.dt );

kev <kevin.porter_at_fast.no> wrote in message news:37D4DCE7.F831494A_at_fast.no...
> Hi,
>
> 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
> latest ten. Or is there some SQL I can use which will select only the
> latest 10 from the DB. It could just as easily be the second, or the
> third ten which I want. It's for a website (using PHP) where I want to
> show 10 news stories, then if a user clicks the 'more' link, the next 10
> are displayed, etc.
>
> TIA,
>
> - Kev
>
Received on Tue Sep 07 1999 - 09:54:24 CDT

Original text of this message

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