select * 
from tbl 
where id in (
select MAX(id) from tbl group by groupid
)
dener misin?