I am trying to find which row has the result produced by MAX(). I've tried quite a few different approaches, but I'm not getting what I want. Here is a simplified example:
This produces:
1 5 4
22 52 5
What I'd like to see is:
88 5 4
116 52 5
How do I get the row that is associated with the MAX found for each category?
Thanks.
Code:
Table: prod_ver
id category version
1 5 3
22 52 3
88 5 4
116 52 5
117 3 2
118 41 1
120 52 2
SELECT p.id, p.category, MAX(version)
FROM prod_ver AS p
WHERE p.cat IN (5,52)
GROUP BY p.category;
This produces:
1 5 4
22 52 5
What I'd like to see is:
88 5 4
116 52 5
How do I get the row that is associated with the MAX found for each category?
Thanks.