title: Postgres SELECT DISTINCT, only highest values
body: <p>I am using the following <code>pgsql</code> query to select <code>index_id</code> and making a distinct query on the level column.</p>
  
  <pre><code>SELECT DISTINCT ON (level) index_id FROM indexes 
  </code></pre>
  
  <p>Although its working, it is returning the first <code>index_id</code> for each level, i would like to get the highest <code>index_id</code> in each distinct level</p>