日期:2014-05-17 浏览次数:20474 次
select d.deptname '部门名称', isnull(m.ct,0) '部门总人数', (select sum(worktask) from tasttime t inner join Member m on t.memberid=m.memberid where m.deptnum=d.deptnum and t.[status]=3 and t.workday>=cast(datename(yyyy,getdate())+'-01-01 00:00:00' as datetime) and datepart(wk,t.workday)=datepart(wk,getdate())-1)/(isnull(m.ct,1)*5) '人均工时(人/天)', (select sum(worktask) from tasttime t inner join Member m on t.memberid=m.memberid where m.deptnum=d.deptnum and t.[status]=3 and t.workday>=cast(datename(yyyy,getdate())+'-01-01 00:00:00' as datetime) and datepart(wk,t.workday)=datepart(wk,getdate())-1)/(8*5) '平均贡献率(%)', (select count(1) from tasttime t inner join Member m on t.memberid=m.memberid where m.deptnum=d.deptnum and t.[status]=3 and t.workday>=cast(datename(yyyy,getdate())+'-01-01 00:00:00' as datetime) and datepart(wk,t.workday)=datepart(wk,getdate())-1 group by t.memberid having cast(sum(worktask)/(8*5) as decimal(5,2))<0.8) '不足80%人员数量', rtrim((select count(1) from tasttime t inner join Member m on t.memberid=m.memberid where m.deptnum=d.deptnum and t.[status]=3 and t.workday>=cast(datename(yyyy,getdate())+'-01-01 00:00:00' as datetime) and datepart(wk,t.workday)=datepart(wk,getdate())-1 group by t.memberid having cast(sum(worktask)/(8*5) as decimal(5,2))<0.8)/ cast(isnull(m.ct,1) as decimal(5,2))*100)+'%' '不足80%人员比例' from dept d left join (select deptnum,count(1) 'ct' from Member group by deptnum) m on d.deptnum=m.deptnum