读书人

sql语句~大侠拜托了。

发布时间: 2012-04-16 16:20:04 作者: rapoo

求一个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) 

读书人网 >SQL Server

热点推荐