Basicly, I have a table with a priority attribute and a value, like
TargetID Priority_Column (int) Value_column
1 1 "value 1"
1 2 "value 2"
1 5 "value 5
2 1 "value 1"
2 2 "value 2"
I want to join another table with this table,
ID Name
1 "name 1"
2 "name 2"
but only using the row with highest priority.
The result would be like
TargetID Priority_Column (int) Name Value_column
1 5 "name 1" "value 5"
2 2 "name 2" "value 2"
I can of course use a high-level language like python to compute highest priority row for each ID.
But that looks inefficient, is there a way to directly do this in sql?