Quantcast
Channel: SQL Query to get latest records for that user - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Tim Biegeleisen for SQL Query to get latest records for that user

$
0
0

Here is one PHP-friendly way to do this, using joins:

SELECT t1.*FROM yourTable t1INNER JOIN(    SELECT id, column1, MAX(completiondate) AS maxcompletiondate    FROM yourTable    GROUP BY id, column1) t2    ON t1.id = t2.id AND       t1.column1 = t2.column1 AND       t1.completiondate = t2.maxcompletiondate;

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>