作者:手机用户2402852307 | 来源:互联网 | 2023-05-18 05:15
这个SQL怎么写原始数据idtimeother22010-1-2a22010-1-3b32010-1-4c32010-1-2d42010-1-2e需要的结果是idtimeother
这个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;欢迎大家阅读《这个SQL如何写》,跪求各位点评,by