统计员工全年各月、季度、年度的任务得分
实现效果:
实现代码(传入参数年,例如:2014):
<!-- 查询-员工任务管理任务数据 -->
<select id="querytaskEmpStaticsTaskScoreForManage" parameterClass="map" resultClass="dto"
remapResults="true">
select a.username,t.a,t.b,t.c,t.d,t.e,t.f,t.g,t.h,t.i,t.j,t.k,t.l
from (SELECT reportuserid,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 1, B.EVALUATESCORE, 0)) AS A,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 2, B.EVALUATESCORE, 0)) AS B,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 3, B.EVALUATESCORE, 0)) AS C,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 4, B.EVALUATESCORE, 0)) AS D,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 5, B.EVALUATESCORE, 0)) AS E,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 6, B.EVALUATESCORE, 0)) AS F,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 7, B.EVALUATESCORE, 0)) AS g,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 8, B.EVALUATESCORE, 0)) AS H,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 9, B.EVALUATESCORE, 0)) AS I,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 10, B.EVALUATESCORE, 0)) AS J,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 11, B.EVALUATESCORE, 0)) AS K,
SUM(DECODE(EXTRACT(MONTH FROM B.taskstartdate), 12, B.EVALUATESCORE, 0)) AS L
FROM gzpt_taskmanager B where 1=1 and b.state=2 and b.enabled=1
<dynamic>
<isNotEmpty prepend="and" property="yearstr">
EXTRACT(YEAR FROM B.taskstartdate) = #yearstr#
</isNotEmpty>
</dynamic>
group by b.reportuserid) t
inner join eauser a on a.userid=t.reportuserid
</select>