postgres select query for 3 column with max
<p>I have this sample table:</p>

<pre><code>id    branch    branch_running_no
1      1         5
2      1         10
3      2         5
4      2         10
5      3         5
6      3         10
7      4         5
8      4         10
9      5         5
10     5         10
</code></pre>

<p>Using this query, I can get the max branch_running_no for each branch column but I also want to include the column id of the max branch_running_no.</p>

<pre><code>SELECT branch, MAX(branch_running_no) from table1 GROUP BY branch order by branch;
</code></pre>

<p>I was able to achieve:</p>

<pre><code>branch    max
1         10
2         10
3         10
4         10
5         10
</code></pre>

<p>but i need:</p>

<pre><code>id    branch    max
2     1         10
4     2         10
6     3         10
8     4         10
10    5         10
</code></pre>