How can I do an sql query where I retrived all the rows in a table except the last 3 (or whatever number) entered.
coopster
1:09 am on Mar 1, 2006 (gmt 0)
I suppose you could run a COUNT(*) aggregate function query first, then use the returned value to subtract 3 to know the LIMIT (assuming the database you are using has some form of LIMIT clause).
LifeinAsia
7:27 pm on Mar 1, 2006 (gmt 0)
Clunky version- something like:
SET @MaxRows = (SELECT COUNT(*) FROM Whatever) - 3;
SELECT TOP @MaxRows FROM Whatever;
The specifics of the code will depend on your DB.
Jose52
7:16 am on Mar 4, 2006 (gmt 0)
Thank you LifeinAsia. I will try that. It makes sense on paper.