首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求一条sql语句,多谢

2012-01-24 
求一条sql语句,谢谢!比如下面的表IDTIME4032006-12-2217:29:46.0004032006-12-2217:39:46.0004032006-12-2

求一条sql语句,谢谢!
比如下面的表
ID                           TIME
4032006-12-22   17:29:46.000
4032006-12-22   17:39:46.000
4032006-12-22   16:06:46.000
2012006-12-22   12:59:52.000
2012006-12-22   12:59:55.000
4032006-12-22   13:00:47.000
2012006-12-22   13:00:55.000
4032006-12-22   13:01:47.000
我只需要选择出如下的结果
4032006-12-22   16:06:46.000
2012006-12-22   12:59:52.000
对于一个ID只取一条记录,sql怎么写呢?



[解决办法]
select * from table1 a where not exists(select 1 from table1 b where a.id=b.id and a.time <b.time)
[解决办法]
select distinct(id),* from table1 where (speed> 20) and time between 'starttime ' and 'endtime '

热点排行
Bad Request.