I have a table with data like this:
Id | Version | isLive
-------+---------+-------
comp1 | 2 | true
comp1 | 3 | true
comp1 | 4 | false
comp1 | 1 | true
comp2 | 4 | true
comp2 | 1 | false
I want to fetch the row that has the highest version number per ID. So there should only be one row per ID.
select id
from mytable
group by id
This returns the data randomly.