写一条sql语句 有每月员工打卡记录表 table

2024-11-29 11:54:29
推荐回答(3个)
回答1:

select distinct userid,times from (select userid,count(userid) as times from table group by userid) where times<20 order by times desc

没调试,大概差不多,试试应该能用

回答2:

select userid,count(userid) as times from table group by userid having count(userid)<20 order by userid

回答3:

select UserID ,count(*)AS CISHU
from table
where SETTIME NOT NULL
GROUP BY USERID
ORDER BY USERID ASC
HAVING CISHU<20