Get the Max number for each group

I am not sure how to word it correctly, so I will just give you an example.

I need a way to get the max id for each group. Most of them are two rows with same SSN, but different ID. I want to be able to get a list of those with higher ID for each group. ID is a PK field. SSN is a social security field and some of then are in it more than once.

Current Result

ID | SSN
05 | 4044
20 | 4044
84 | 5231
44 | 5231

Desired Results. This is what I need my result to show.

ID | SSN
20 | 4044
84 | 5231

select max(id), ssn 
from mytable
group by ssn
2 Likes

Wow. That simple. Thank you. I will try it.

Easy when you know how ... until then its hard :smile:

1 Like