Re: Help- query for last x items
From: Shay Shmelzer <shmelzer_at_johnbryce.co.il>
Date: 1996/09/09
Message-ID: <3233F44F.ED5_at_johnbryce.co.il>#1/1
Date: 1996/09/09
Message-ID: <3233F44F.ED5_at_johnbryce.co.il>#1/1
Jason Yeoung Zien wrote:
>
> Hi,
>
> Can anyone tell me how to efficiently query for the last X
> items in a sorted subset?
>
> For example my initial attempt was,
>
>
> select * from access_log where type='user'
> where (rownum < X) and (rownum> X-100) /* <--- this is wrong */
> order by access_date desc
Simply reverse(asc) your order by and select the first 100 .(rownum
<101);
this will give u the same as the last 100 with a desc order by .
-- ++++++++++++++++++++++++++++++++++ |\/\/\| Shay Shmelzer | | E-mail : shmelzer_at_johnbryce.co.il OO ) Phone : 972-3-5765647 ISRAEL c | Organization: John Bryce Systems /___/ | ++++++++++++++++++++++++++++++++++ ) (Received on Mon Sep 09 1996 - 00:00:00 CEST
