This answer from Bill Karwin to question 121387 worked perfectly for me..
“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;
In other words: fetch the row from t1 where no other row exists with the same UserId and a greater Date.”
However, I also need to include in the result a column from a third table (imagine another table with UserId and UserPhoneNumber columns). It feels as if it should be straightforward but it’s driving me nuts. Any help would be appreciated.
Simply join the third table after the LEFT JOIN: