日期:2014-05-18  浏览次数:20595 次

请教select的问题!急!
account               date

0001                 1982年3月3日     08:00
0001                 1982年3月3日     09:15
0001                 1982年3月3日     10:09
0002                 1982年3月4日     09:10
.
.
.
我的表格中的数据如上,我想要select出的记录是:   如果如上是上班打卡系统的打卡记录的话,我想找出迟到的人有哪些,就是找出每天第一次打卡时间在08:10与08:30之间的记录,query文应该怎么写,请高手帮忙,在线等,急!!

------解决方案--------------------
create table T(account varchar(10), [date] datetime)
insert T select '0001 ', '1982-3-3 08:00 '
union all select '0001 ', '1982-3-3 09:15 '
union all select '0001 ', '1982-3-3 10:09 '
union all select '0002 ', '1982-3-4 09:10 '

select * from T
where dateadd(day, -datediff(day, '1900-01-01 ', [date]), [date])
between '1900-01-01 08:10 ' and '1900-01-01 08:30 '
order by [date] desc