一个sql查询问题,感觉很难
一张log表,有login_time,role_id俩字段,我需要查询周一到周五每天都有login_time登陆记录的role_id,想半天实在是想不出来。。。。。。。
[解决办法]
试试
select role_id
from log
where DATEPART(WEEKDAY,login_time) between 2 and 6
group by role_id
having count(login_time)=5
select?role_id
from?log
where?DATEPART(WEEKDAY,login_time)?between?2?and?6
group?by?role_id
having?count(discint convert(date,login_time))=5