Groups | Blog | Home
all groups > sql server (microsoft) > february 2006 >

sql server (microsoft) : SQL 2000 equivalent of "Last(x)"


Douglas J. Steele
2/24/2006 5:59:35 PM
Realistically, Last isn't a particular reliable function, since it depends
on the order of the records, and you can never assume anything about the
order of the records in a table. That means you must use a query with an
ORDER BY clause in order to be sure of the order. If your ORDER BY is
sorting in ascending order, reverse it to sort by descending order, and use
TOP 1 to get the last row.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


[quoted text, click to view]

RTL
2/24/2006 8:20:12 PM
I can't seem to find that command in the SQL 2000 reference. By chance,
would any gurus know it? I have a query that is producing very bad reports
(off by 30K) with a query that _should be_ functionally equivalent; but is
not it seems. The only inherent difference is the Access SQL call uses
Last(x) function and SQL query does not.

Thanks in advance and enjoy your weekends,

Rich

Mano Bains
2/26/2006 7:46:26 PM
Use;

"Select MAX(x)
from dbo.y"

where x is the unique identifier and y is the table name.


Regards,


[quoted text, click to view]

RTL
2/27/2006 4:25:39 PM
Thank you both for responding. That did solve the problem...both produced
the results I was looking for.

Cheers,

Rich


[quoted text, click to view]

AddThis Social Bookmark Button