试试select role_id
from log
where DATEPART(WEEKDAY,login_time) between 2 and 6
group by role_id
having count(login_time)=5
from log
where DATEPART(WEEKDAY,login_time) between 2 and 6
group by role_id
having count(login_time)=5
from log
where DATEPART(WEEKDAY,login_time) between 2 and 6
group by role_id
having count(discint convert(date,login_time))=5
最后一句改了一直报错。。改成这样试试:select role_id
from log
where DATEPART(WEEKDAY,login_time) between 2 and 6
group by role_id
having count(distinct convert(date,login_time))=5
from log
where login_time between @begin_time and @end_time
group by role_id
having count(distinct convert(varchar(10),login_time,121))=5