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
Answer
Use order by
to get the max index_id
SELECT DISTINCT ON (level) index_id
FROM indexes
order by level, index_id desc
No comments:
Post a Comment