试试select role_id
from log
where DATEPART(WEEKDAY,login_time) between 2 and 6
group by role_id
having count(login_time)=5

解决方案 »

  1.   

    DATEPART(WEEKDAY,login_time) between 2 and 6 这个什么意思?(login_time)=5 这个不对吧,如果一天内登录5次,其它几天没有登录呢
      

  2.   

    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
      

  3.   


    最后一句改了一直报错。。改成这样试试: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
      

  4.   

    ........不好意思,distinct少了个字母,按6楼的写法试试
      

  5.   

    我觉得是你自己把你自己陷进去了吧,你这个需求肯定有一个查询时间段啊,否则有什么意义呢。如果你在时间段内已经限制为某一周了,那么下面的就可以select role_id
    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