oracle - SQL - fetch the row which has the Max value for a column - Stack Overflow:

I see many people use subqueries or else vendor-specific features to do this, but I often do this kind of query without subqueries in the following way. It uses plain, standard SQL so it should work in any brand of RDBMS.

SELECT t1.*
FROM mytable AS t1
LEFT OUTER JOIN mytable AS t2
ON (t1.UserId = t2.UserId AND t1.'Date' < t2.'Date')
WHERE t2.UserId IS NULL


Well played, Mr. Karwin.

Labels: , ,