|
|
@ -248,26 +248,22 @@ |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectAgencyScoreAvgExistsSubNew" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO"> |
|
|
|
SELECT a2.pid AS parentId,a.monthId,a.quarterId,a.yearId,ROUND(AVG( a.score ),6) AS score,a.customerId,a.parentId AS agencyId FROM |
|
|
|
(SELECT |
|
|
|
sca.agency_id AS agencyId, |
|
|
|
fics.month_id AS monthId, |
|
|
|
fics.quarter_id AS quarterId, |
|
|
|
fics.year_id AS yearId, |
|
|
|
IFNULL(ROUND(AVG( fics.score ),6),0) AS score, |
|
|
|
sca.customer_id AS customerId, |
|
|
|
(SELECT AGENCY_ID FROM screen_customer_agency WHERE AREA_CODE = #{areaCode} AND DEL_FLAG = 0) AS parentId |
|
|
|
FROM screen_customer_agency sca |
|
|
|
LEFT JOIN fact_index_agency_score fics ON |
|
|
|
(fics.agency_id = sca.agency_id |
|
|
|
AND fics.del_flag = '0' |
|
|
|
AND fics.month_id = #{monthId} |
|
|
|
AND fics.index_code = #{indexCode} |
|
|
|
AND fics.agency_id IN (SELECT AGENCY_ID FROM screen_customer_agency WHERE PARENT_AREA_CODE = #{areaCode} AND DEL_FLAG = 0) |
|
|
|
) |
|
|
|
WHERE sca.DEL_FLAG = '0' |
|
|
|
GROUP BY agencyId) a |
|
|
|
LEFT JOIN screen_customer_agency a2 ON a2.AGENCY_ID = a.parentId AND a2.DEL_FLAG = 0 |
|
|
|
GROUP BY a2.AGENCY_ID |
|
|
|
SELECT |
|
|
|
sca.agency_id AS agencyId, |
|
|
|
#{monthId} AS monthId, |
|
|
|
#{quarterId} AS quarterId, |
|
|
|
#{yearId} AS yearId, |
|
|
|
IFNULL(ROUND(AVG( fics.score ),6),0) AS score, |
|
|
|
sca.customer_id AS customerId, |
|
|
|
(SELECT AGENCY_ID FROM screen_customer_agency WHERE AREA_CODE = #{areaCode} AND DEL_FLAG = 0) AS parentId |
|
|
|
FROM screen_customer_agency sca |
|
|
|
LEFT JOIN fact_index_agency_score fics ON |
|
|
|
(fics.agency_id = sca.agency_id |
|
|
|
AND fics.del_flag = '0' |
|
|
|
AND fics.month_id = #{monthId} |
|
|
|
AND fics.index_code = #{indexCode}) |
|
|
|
WHERE sca.DEL_FLAG = '0' |
|
|
|
AND sca.PARENT_AREA_CODE = #{areaCode} |
|
|
|
GROUP BY parentId |
|
|
|
</select> |
|
|
|
</mapper> |
|
|
|