表:table
id revtime val
1 2006-1-1 12:00:00 22
1 2006-1-1 15:00:00 55
1 2006-1-2 12:00:00 46
1 2006-1-2 22:00:00 44
1 2006-1-3 11:00:00 89
1 2006-1-3 12:00:00 100
2 2006-1-1 12:00:00 90怎样查询id=1的每天最后一条数据?
id revtime val
1 2006-1-1 12:00:00 22
1 2006-1-1 15:00:00 55
1 2006-1-2 12:00:00 46
1 2006-1-2 22:00:00 44
1 2006-1-3 11:00:00 89
1 2006-1-3 12:00:00 100
2 2006-1-1 12:00:00 90怎样查询id=1的每天最后一条数据?
可以不
select top 1 * from table where id = 1 order by revtime desc
where id =1 group by left(revtime,10)) as sh where id= 1 and [table].revtime=sh.r
where id =1 group by left(revtime,10)) as sh where id= 1 and [table].revtime=sh.r