diff --git a/src/main/resources/sqlmapper/mappers/report/reportGoal.xml b/src/main/resources/sqlmapper/mappers/report/reportGoal.xml index 197f706..40cce58 100644 --- a/src/main/resources/sqlmapper/mappers/report/reportGoal.xml +++ b/src/main/resources/sqlmapper/mappers/report/reportGoal.xml @@ -108,28 +108,49 @@ + select (row_number() over()) AS rn, + t.* + from ( + SELECT p.code2 AS CODE, + p.codenm AS NAME, + coalesce(go_goal1, 0) AS GOAL1, + coalesce(go_goal2, 0) AS GOAL2, + coalesce(go_goal3, 0) AS GOAL3, + coalesce(go_goal4, 0) AS GOAL4, + coalesce(go_total, 0) AS GOAL_TOTAL, + coalesce(ri.result1, 0) AS RESULT1, + coalesce(ri.result2, 0) AS RESULT2, + coalesce(ri.result3, 0) AS RESULT3, + coalesce(ri.result4, 0) AS RESULT4, + coalesce(ri.result_total, 0) AS RESULT_TOTAL + from tcode p + left outer join ( + select go_place1, + sum(go_goal1) as go_goal1, + sum(go_goal2) as go_goal2, + sum(go_goal3) as go_goal3, + sum(go_goal4) as go_goal4, + 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 + \ No newline at end of file