当前位置: 代码迷 >> Sql Server >> sql语句~大侠拜托了。
  详细解决方案

sql语句~大侠拜托了。

热度:56   发布时间:2016-04-27 13:25:34.0
求一个sql语句~~~大侠拜托了。。。
比如有个表table
id col datetime
1 aa 2012-01-01
2 aa 2012-01-03
3 bb 2012-03-01
4 cc 2011-10-12
5 bb 2013-11-11

我要得到
2 aa 2012-01-03
5 bb 2013-11-11
4 cc 2011-10-12


就是col字段相同的,只取datetime最后的那一条记录~~拜托了~~

------解决方案--------------------
SQL code
select *from tb twhere not exists (select 1 from tb where col=t.col and date>t.date)
  相关解决方案