select * tb a,
(select type,max(id) as id from TB GROUP by type) b
where a.type=b.type and a.id=b.id