SELECT f.scd_evaluation_id , f.scd_section_id , CASE WHEN a.total_cnt IS NULL THEN 0 ELSE a.total_cnt END AS total_cnt , CASE WHEN r.submit_cnt IS NULL THEN 0 ELSE r.submit_cnt END AS submit_cnt FROM ( SELECT s.scd_evaluation_id , s.scd_section_id , COUNT(1) AS submit_cnt FROM ps_scd_usr_eval_hd h INNER JOIN ps_scd_usreval_sct s ON h.scd_evaluation_id = s.scd_evaluation_id AND h.scd_evaluator_id = s.scd_evaluator_id WHERE s.select_flag = 'Y' AND h.scd_resp_status IN ('SU', 'OM', 'DE') GROUP BY s.scd_evaluation_id, s.scd_section_id) r RIGHT JOIN ( SELECT s.scd_evaluation_id , s.scd_section_id , COUNT(1) AS total_cnt FROM ps_scd_usreval_sct s WHERE s.select_flag = 'Y' GROUP BY s.scd_evaluation_id, s.scd_section_id) a ON r.scd_evaluation_id = a.scd_evaluation_id AND r.scd_section_id = a.scd_section_id RIGHT JOIN ( SELECT bs.scd_evaluation_id , bs.scd_section_id FROM PS_SCD_BLD_SECTS bs) f ON a.scd_evaluation_id = f.scd_evaluation_id AND a.scd_section_id = f.scd_section_id
|