table join with priority attribute
<p>Basicly, I have a table with a priority attribute and a value, like</p>

<pre><code>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"
</code></pre>

<p>I want to join another table with this table, </p>

<pre><code> ID  Name
 1   "name 1"
 2   "name 2"
</code></pre>

<p>but only using the row with highest priority.</p>

<p>The result would be like</p>

<pre><code>TargetID Priority_Column (int)  Name        Value_column
1                  5            "name 1"    "value 5"
2                  2            "name 2"    "value 2"
</code></pre>

<p>I can of course use a high-level language like python to compute highest priority row for each ID. </p>

<p>But that looks inefficient, is there a way to directly do this in sql?</p>