For each ID number, I need to group ID numbers by class values, using the lowest rank when there are duplicate class values…I have tried several joins with no success. Would appreciate a VERY brief description for any code suggested. Thanks!
Table Structure:
ID Rank Class
A 1 x
A 2 x
A 3 y
A 4 y
B 1 x
B 2 x
B 3 y
B 4 y
Desired Result:
ID Rank Class
A 1 x
A 3 y
B 1 x
B 3 y
You should use an aggregate function
MIN()with aGROUP BYtheidandclass:See SQL Fiddle with Demo