Zajímalo by mě, jestli by to fungovalo: select * from table where id in (select distinct max(id) from table group by name)