My table :
| id | role |
|---|---|
| b | f |
| b | s |
| b | g |
| a | s |
| a | f |
| c | f |
I want a distinct id but with corresponding role, with this logic:
If g exists select g if not
if s exists select s if not
if f exists select f.
Query should yield :
| id | role |
|---|---|
| b | g |
| a | s |
| c | f |
I tried group by id, but role cannot be sorted in a useful order.