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

求一个统计每天某一时间段的SQL语句
我的表结构
id     cardid                 name           zhiwu         time
1       2001051 王帅 教师 2007-3-1   8:34:15
2       2001052               赵大                               2007-3-2   10:58:00

现在想统计每天7:50至10:00签到的人,请问如何实现?比如指定开始时间为1月1日,结束时间为3月30日,想查一下这段时间内,7:50至10:00签到的人?



------解决方案--------------------
select
convert(char(10),time,120),count(*)
from
t
where
time between '2007-01-01 00:00:00 ' and '2007-03-30 23:59:59 '
and
convert(char(8),time,108) between '07:50:00 ' and '10:00:00 '
group by
convert(char(10),time,120)