I am using the following pgsql query to select index_id and making a distinct query on the level column.
SELECT DISTINCT ON (level) index_id FROM indexes 
Although its working, it is returning the first index_id for each level, i would like to get the highest index_id in each distinct level
 
     
     
    