January 26, 2006 at 10:08 am
I need to create a dataset (working with ASP.NET) based on a selected retrieving the 6 most recent records (based on a date) after the most recent.
In other words:
2006/01/25 9PM20
2006/01/24 3PM30
2006/01/24 9AM20
2006/01/23 9PM20
2006/01/22 9PM20
2006/01/21 9PM20
2006/01/20 9PM20
It should retrieve all rows except 2006/01/25 9PM20
Any idea on how I should write the SQL Statement ?
Jean-Luc
www.corobori.com
January 26, 2006 at 10:41 am
Something like this?
select top 6 myfield
from mytable
where mytable.myfield <> (select max(myfield)
from mytable)
order by myfield
January 26, 2006 at 10:49 am
Shame on me ! It was so easy
Thanks
Jean-Luc
www.corobori.com
January 26, 2006 at 10:55 am
Sometimes you can't see the forest because of those damn trees.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply