日期:2014-05-16  浏览次数:20819 次

这个SQL怎么写
原始数据
id time other
2 2010-1-2 a
2 2010-1-3 b
3 2010-1-4 c
3 2010-1-2 d
4 2010-1-2 e
需要的结果是
id time other
2 2010-1-3 b
3 2010-1-4 c
4 2010-1-2 e

每个id只取一项,这项是关于时间最新的。

------解决方案--------------------
SQL code

select * from table a where not exists(select 1 from table where id=a.id and time>a.time) order by a.id;