-- 方法1 select a.* from table1 a where not exists(select 1 from table1 b where b.name=a.name and b.gdtime>a.gdtime) -- 方法2 select a.* from table1 a inner join (select name, max(gdtime) 'maxgdtime' from table1 group by name) b on a.name=b.name and a.gdtime=b.maxgdtime
测试三百万条数据查询后,方法2查询速度更快,建议使用第二种 关联查询法