Let’s say I have this query:
SELECT report_id, time_sent
FROM report_submissions
WHERE report_id IN (1,2,3,4,5,6)
ORDER BY report_id ASC, time_sent DESC
with this result:
report_id time_sent
1 2
1 1
2 4
2 3
3 4
And I want to change that query so I will get a DISTINCT report_id with its max(time_sent), for example:
report_id time_sent
1 2
2 4
3 4
How do I do that in the most efficient way? Thanks.
1 Answer