SQL 2000 equivalent of "Last(x)"

R

RTL

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
 
D

Douglas J. Steele

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.
 
M

Mano Bains

Use;

"Select MAX(x)
from dbo.y"

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


Regards,
 
R

RTL

Thank you both for responding. That did solve the problem...both produced
the results I was looking for.

Cheers,

Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top