62,046
社区成员
发帖
与我相关
我的任务
分享
Select BeChecker,
sum(case when month(CheckTime)=1 then 1 else 0 end) as month1,
sum(case when month(CheckTime)=2 then 1 else 0 end) as month2,
sum(case when month(CheckTime)=3 then 1 else 0 end) as month3,
sum(case when month(CheckTime)=4 then 1 else 0 end) as month4,
sum(case when month(CheckTime)=5 then 1 else 0 end) as month5,
sum(case when month(CheckTime)=6 then 1 else 0 end) as month6,
sum(case when month(CheckTime)=7 then 1 else 0 end) as month7,
sum(case when month(CheckTime)=8 then 1 else 0 end) as month8,
sum(case when month(CheckTime)=9 then 1 else 0 end) as month9,
sum(case when month(CheckTime)=10 then 1 else 0 end) as month10,
sum(case when month(CheckTime)=11 then 1 else 0 end) as month11,
sum(case when month(CheckTime)=12 then 1 else 0 end) as month12
from 查岗登记where year(CheckTime)='2009' group by BeChecker
Select BeChecker,
sum(case when month(CheckTime)=1 then 1 else 0 end) as 1月,
sum(case when month(CheckTime)=2 then 1 else 0 end) as 2月,
....
sum(case when month(CheckTime)=12 then 1 else 0 end) as 12月
from 查岗登记 where year(CheckTime)='2009' group by BeChecker
isnull(字段,0)
若为空显示0