11.24.2014

Get Latest Records SQL

Using this SQL:

SELECT sb1.date, sb1.branch, sb1.build
FROM stable_builds sb1
INNER JOIN (
    SELECT max(date) date, branch
    FROM stable_builds
    GROUP BY branch
) AS sb2
ON sb1.branch = sb2.branch
AND sb1.date = sb2.date
ORDER BY date DESC

Data:
Date Branch Build   
2014-11-24 5.6 460049
2014-11-19 5.6 459641
2014-11-16 5.6 459347

Output:
Date Branch Build   
2014-11-24 5.6 460049

No comments:

Post a Comment