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

请问select的有关问题!

2012-03-30 
请教select的问题!急!accountdate00011982年3月3日08:0000011982年3月3日09:1500011982年3月3日10:0900021

请教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

热点排行