견문보고>관리기능>목표/실적조회 부서별 조회 오류 수정.

master
강석 최 2022-05-27 17:40:17 +09:00
parent 6a2219e829
commit bb9ffb8a41
1 changed files with 45 additions and 24 deletions

View File

@ -108,28 +108,49 @@
</select> </select>
<select id="ReportGoal.getStatsPlace" parameterType="reportSearchVO" resultType="hashMap"> <select id="ReportGoal.getStatsPlace" parameterType="reportSearchVO" resultType="hashMap">
SELECT select (row_number() over()) AS rn,
ROWNUM AS RN, T.* t.*
FROM from (
( SELECT p.code2 AS CODE,
SELECT p.codenm AS NAME,
CODE2 AS CODE, CODENM AS NAME, coalesce(go_goal1, 0) AS GOAL1,
SUM(COALESCE(GO_GOAL1, 0)) AS GOAL1, SUM(COALESCE(GO_GOAL2, 0)) AS GOAL2, SUM(COALESCE(GO_GOAL3, 0)) AS GOAL3, SUM(COALESCE(GO_GOAL4, 0)) AS GOAL4, coalesce(go_goal2, 0) AS GOAL2,
SUM(COALESCE(GO_GOAL1, 0)) + SUM(COALESCE(GO_GOAL2, 0)) + SUM(COALESCE(GO_GOAL3, 0)) + SUM(COALESCE(GO_GOAL4, 0)) AS GOAL_TOTAL, coalesce(go_goal3, 0) AS GOAL3,
(SELECT COUNT(*) FROM RPT_INFO WHERE IN_COMPLETE = 1 AND IN_INFO_YEAR = G.GO_YEAR AND IN_INFO_MONTH = G.GO_MONTH AND IN_CATEGORY4 = '01') AS RESULT1, coalesce(go_goal4, 0) AS GOAL4,
(SELECT COUNT(*) FROM RPT_INFO WHERE IN_COMPLETE = 1 AND IN_INFO_YEAR = G.GO_YEAR AND IN_INFO_MONTH = G.GO_MONTH AND IN_CATEGORY4 = '02') AS RESULT2, coalesce(go_total, 0) AS GOAL_TOTAL,
(SELECT COUNT(*) FROM RPT_INFO WHERE IN_COMPLETE = 1 AND IN_INFO_YEAR = G.GO_YEAR AND IN_INFO_MONTH = G.GO_MONTH AND IN_CATEGORY4 IN ('03', '04', '05')) AS RESULT3, coalesce(ri.result1, 0) AS RESULT1,
(SELECT COUNT(*) FROM RPT_INFO WHERE IN_COMPLETE = 1 AND IN_INFO_YEAR = G.GO_YEAR AND IN_INFO_MONTH = G.GO_MONTH AND IN_CATEGORY4 = '06') AS RESULT4, coalesce(ri.result2, 0) AS RESULT2,
(SELECT COUNT(*) FROM RPT_INFO WHERE IN_COMPLETE = 1 AND IN_INFO_YEAR = G.GO_YEAR AND IN_INFO_MONTH = G.GO_MONTH) AS RESULT_TOTAL coalesce(ri.result3, 0) AS RESULT3,
FROM coalesce(ri.result4, 0) AS RESULT4,
(SELECT * FROM TCODE WHERE CODE1 = 'C001') P coalesce(ri.result_total, 0) AS RESULT_TOTAL
LEFT OUTER JOIN from tcode p
(SELECT DISTINCT * FROM RPT_AGENT_GOAL WHERE GO_YEAR = #{year} AND GO_MONTH = #{month}) G left outer join (
ON G.GO_PLACE1 = P.CODE2 select go_place1,
GROUP BY sum(go_goal1) as go_goal1,
CODE2, CODENM, GO_YEAR, GO_MONTH sum(go_goal2) as go_goal2,
ORDER BY sum(go_goal3) as go_goal3,
CODE2 sum(go_goal4) as go_goal4,
) T sum(go_total) as go_total
from RPT_AGENT_GOAL
where go_year = ${year}
and go_month = ${month}
group by go_place1
) G ON G.GO_PLACE1 = P.CODE2
left outer join (
select in_place_code,
count(1) filter (where in_category4 = '01') as result1,
count(1) filter (where in_category4 = '02') as result2,
count(1) filter (where in_category4 in ('03', '04', '05')) as result3,
count(1) filter (where in_category4 = '06') as result4,
count(1) as result_total
from rpt_info
where in_complete = '1'
and in_info_year = ${year}
and in_info_month = ${month}
group by in_place_code
) ri on p.code2 = ri.in_place_code
WHERE p.code1 = 'C001'
order by p.code2
) t
</select> </select>
</mapper> </mapper>