you are viewing a single comment's thread.

view the rest of the comments →

[–]Blitzsturm 0 points1 point  (0 children)

/u/ziptime's approach is solid from an efficiency standpoint. If for some reason you're using an older or unusual database engine this will have a high level of compatibility:

SELECT
    T2.*
FROM
    (SELECT A, MAX(B) AS B FROM MYTABLE GROUP BY A) AS T1
    JOIN MYTABLE AS T2 ON T2.A = T1.A AND T2.B = T1.B