在sql sever中怎么查询一周内每天中某个时间段内的数据

2024-12-02 03:36:38
推荐回答(1个)
回答1:

select count(scan_time)
from a
where scan_time between '2017-08-01' and '2017-08-07 12:00'
and ((datepart(hour,scan_time)=1 and datepart(MINUTE,scan_time)>=15)
or (datepart(hour,scan_time)>=2 and datepart(hour,scan_time)<=12))