Help- query for last x items

From: Jason Yeoung Zien <zien_at_cse.ucsc.edu>
Date: 1996/09/06
Message-ID: <50q61r$j4k_at_darkstar.ucsc.edu>#1/1


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
	

One solution would be to just query without the "where" clause and to loop through the cursor and ignore the items outside of the proper range, but that seems inelegant. Received on Fri Sep 06 1996 - 00:00:00 CEST

Original text of this message