22,207
社区成员
发帖
与我相关
我的任务
分享
select SName,count(1) 上班天数,sum(case when state=1 then 1 else 0 end) 没有迟到天数
from tb where Stime>7 group by SName
select SName,count(1) 天数 from tb where Stime>7 and state=1 group by SName
不是你要的?--1
select SName,count(1) 天数 from tb where Stime>7 and state<>1 group by SName
--2
select SName,sum(天数) as 天数
from (
select SName,count(1) 天数 from tb1 where Stime>7 and state<>1 group by SName
union all
select SName,count(1) 天数 from tb2 where Stime>7 and state<>1 group by SName) a
group by SName