I have the below data:
id1 | id2 | other |
---|---|---|
1 | a | p |
1 | b | q |
2 | c | q |
2 | d | q |
2 | e | q |
I want to select distinct id1
. For id2
, I just want the first occurrence - I don't care about the rest like this:
id1 | id2 |
---|---|
1 | a |
2 | c |
Thanks!
CodePudding user response:
Should be fairly simple:
select id1, min(id2) as id2
from that_table
group by id1