我想,你想要这个?
select * from docs where (id, rev) IN (select id, max(rev) as rev from docs group by id order by id)
SQL小提琴: Check here