1.根据名称分组去重,并查询记录ID
select max(id) from T_TABLE GROUP BY name
2.根据ID获取记录
select * from T_TABLE where ID in ( select max(id) from T_TABLE GROUP BY name )