sql 2000 查询某个月度时间最晚的一条记录
sql 2000 查询某个月份时间最晚的一条记录
如果要查询5月份的时间最晚的记录
则查询结果为 id 号为 8的那条记录
------解决方案--------------------
select * from tt a where not exists(select 1 from tt where
convert(varchar(7),a.f1,120)=convert(varchar(7),f1,120)
and a.f1<f1)
------解决方案--------------------
7 519 64 519 2012-05-13 10:50:15.327
8 519 64 697 2012-05-14 10:50:26.857
9 519 64 222 2012-06-14 10:50:36.967
如果要查询5月份的时间最晚的记录
则查询结果为 id 号为 8的那条记录
8 519 64 697 2012-05-14 10:50:26.857
------解决方案--------------------
select * from tt a where not exists(select 1 from tt where
convert(varchar(7),a.f1,120)=convert(varchar(7),f1,120)
and a.f1<f1)
------解决方案--------------------
select top 1 * from table1 a
where 时间 between '2012-05-01' and '2012-06-01'
order by 时间 desc