SQL考勤统计语句,求助

2025-04-05 17:50:10
推荐回答(1个)
回答1:

select name,
sum(case when intime between '8:00' and '8:29' then 1 else 0 end ) as '迟到',
sum(case when intime between '8:30' and '9:00' then 1 else 0 end ) as '缺勤'
from table1
group by name

因为“8:30”是一个公用时间点,不能判别式迟到还是缺勤,
所以迟到我换成“8:29”了