|
|
@ -19,15 +19,15 @@
|
|
|
|
, IF(tpi.prtm_se_nm = '비마약류', 1, 0) AS 비마약류
|
|
|
|
, IF(tpi.prtm_se_nm = '비마약류', 1, 0) AS 비마약류
|
|
|
|
, IF(tpi.prtm_se_nm = '일반관리대상', 1, 0) AS 일반관리대상
|
|
|
|
, IF(tpi.prtm_se_nm = '일반관리대상', 1, 0) AS 일반관리대상
|
|
|
|
, IF(tpi.prtm_se_nm = '중점관리대상', 1, 0) AS 중점관리대상
|
|
|
|
, IF(tpi.prtm_se_nm = '중점관리대상', 1, 0) AS 중점관리대상
|
|
|
|
, IF(tpi.nrcd_se_nm = '대마', tdmd.dsuse_qy, '0') AS 대마qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '대마', tdmd.dsuse_qy, '0') AS 대마Qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '마약', tdmd.dsuse_qy, '0') AS 마약qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '마약', tdmd.dsuse_qy, '0') AS 마약Qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '한외마약', tdmd.dsuse_qy, '0') AS 한외마약qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '한외마약', tdmd.dsuse_qy, '0') AS 한외마약Qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '향정', tdmd.dsuse_qy, '0') AS 향정qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '향정', tdmd.dsuse_qy, '0') AS 향정Qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '향정제외', tdmd.dsuse_qy, '0') AS 향정제외qy
|
|
|
|
, IF(tpi.nrcd_se_nm = '향정제외', tdmd.dsuse_qy, '0') AS 향정제외Qy
|
|
|
|
, IF(tpi.nrcd_se_nm IS NULL, tdmd.dsuse_qy, '0') AS 기타qy
|
|
|
|
, IF(tpi.nrcd_se_nm IS NULL, tdmd.dsuse_qy, '0') AS 기타Qy
|
|
|
|
, IF(tpi.prtm_se_nm = '비마약류', tdmd.dsuse_qy, 0) AS 비마약류qy
|
|
|
|
, IF(tpi.prtm_se_nm = '비마약류', tdmd.dsuse_qy, 0) AS 비마약류Qy
|
|
|
|
, IF(tpi.prtm_se_nm = '일반관리대상', tdmd.dsuse_qy, 0) AS 일반관리대상qy
|
|
|
|
, IF(tpi.prtm_se_nm = '일반관리대상', tdmd.dsuse_qy, 0) AS 일반관리대상Qy
|
|
|
|
, IF(tpi.prtm_se_nm = '중점관리대상', tdmd.dsuse_qy, 0) AS 중점관리대상qy
|
|
|
|
, IF(tpi.prtm_se_nm = '중점관리대상', tdmd.dsuse_qy, 0) AS 중점관리대상Qy
|
|
|
|
FROM tb_dsuse_mgt tdm
|
|
|
|
FROM tb_dsuse_mgt tdm
|
|
|
|
JOIN tb_dsuse_mgt_dtl tdmd ON tdm.dscdmng_id = tdmd.dscdmng_id
|
|
|
|
JOIN tb_dsuse_mgt_dtl tdmd ON tdm.dscdmng_id = tdmd.dscdmng_id
|
|
|
|
JOIN tb_prduct_info tpi ON tdmd.prduct_cd = tpi.prduct_cd
|
|
|
|
JOIN tb_prduct_info tpi ON tdmd.prduct_cd = tpi.prduct_cd
|
|
|
@ -61,15 +61,15 @@
|
|
|
|
, SUM(tgt.비마약류) AS 비마약류
|
|
|
|
, SUM(tgt.비마약류) AS 비마약류
|
|
|
|
, SUM(tgt.일반관리대상) AS 일반관리대상
|
|
|
|
, SUM(tgt.일반관리대상) AS 일반관리대상
|
|
|
|
, SUM(tgt.중점관리대상) AS 중점관리대상
|
|
|
|
, SUM(tgt.중점관리대상) AS 중점관리대상
|
|
|
|
, SUM(tgt.대마qy) AS 대마qy
|
|
|
|
, SUM(tgt.대마Qy) AS 대마Qy
|
|
|
|
, SUM(tgt.마약qy) AS 마약qy
|
|
|
|
, SUM(tgt.마약Qy) AS 마약Qy
|
|
|
|
, SUM(tgt.한외마약qy) AS 한외마약qy
|
|
|
|
, SUM(tgt.한외마약Qy) AS 한외마약Qy
|
|
|
|
, SUM(tgt.향정qy) AS 향정qy
|
|
|
|
, SUM(tgt.향정Qy) AS 향정Qy
|
|
|
|
, SUM(tgt.향정제외qy) AS 향정제외qy
|
|
|
|
, SUM(tgt.향정제외Qy) AS 향정제외Qy
|
|
|
|
, SUM(tgt.기타qy) AS 기타qy
|
|
|
|
, SUM(tgt.기타Qy) AS 기타Qy
|
|
|
|
, SUM(tgt.비마약류qy) AS 비마약류qy
|
|
|
|
, SUM(tgt.비마약류Qy) AS 비마약류Qy
|
|
|
|
, SUM(tgt.일반관리대상qy) AS 일반관리대상qy
|
|
|
|
, SUM(tgt.일반관리대상Qy) AS 일반관리대상Qy
|
|
|
|
, SUM(tgt.중점관리대상qy) AS 중점관리대상qy
|
|
|
|
, SUM(tgt.중점관리대상Qy) AS 중점관리대상Qy
|
|
|
|
FROM tgt
|
|
|
|
FROM tgt
|
|
|
|
GROUP BY tgt.dept_cd
|
|
|
|
GROUP BY tgt.dept_cd
|
|
|
|
UNION ALL
|
|
|
|
UNION ALL
|
|
|
@ -85,15 +85,15 @@
|
|
|
|
, SUM(tgt.비마약류) AS 비마약류
|
|
|
|
, SUM(tgt.비마약류) AS 비마약류
|
|
|
|
, SUM(tgt.일반관리대상) AS 일반관리대상
|
|
|
|
, SUM(tgt.일반관리대상) AS 일반관리대상
|
|
|
|
, SUM(tgt.중점관리대상) AS 중점관리대상
|
|
|
|
, SUM(tgt.중점관리대상) AS 중점관리대상
|
|
|
|
, SUM(tgt.대마qy) AS 대마qy
|
|
|
|
, SUM(tgt.대마Qy) AS 대마Qy
|
|
|
|
, SUM(tgt.마약qy) AS 마약qy
|
|
|
|
, SUM(tgt.마약Qy) AS 마약Qy
|
|
|
|
, SUM(tgt.한외마약qy) AS 한외마약qy
|
|
|
|
, SUM(tgt.한외마약Qy) AS 한외마약Qy
|
|
|
|
, SUM(tgt.향정qy) AS 향정qy
|
|
|
|
, SUM(tgt.향정Qy) AS 향정Qy
|
|
|
|
, SUM(tgt.향정제외qy) AS 향정제외qy
|
|
|
|
, SUM(tgt.향정제외Qy) AS 향정제외Qy
|
|
|
|
, SUM(tgt.기타qy) AS 기타qy
|
|
|
|
, SUM(tgt.기타Qy) AS 기타Qy
|
|
|
|
, SUM(tgt.비마약류qy) AS 비마약류qy
|
|
|
|
, SUM(tgt.비마약류Qy) AS 비마약류Qy
|
|
|
|
, SUM(tgt.일반관리대상qy) AS 일반관리대상qy
|
|
|
|
, SUM(tgt.일반관리대상Qy) AS 일반관리대상Qy
|
|
|
|
, SUM(tgt.중점관리대상qy) AS 중점관리대상qy
|
|
|
|
, SUM(tgt.중점관리대상Qy) AS 중점관리대상Qy
|
|
|
|
FROM tgt
|
|
|
|
FROM tgt
|
|
|
|
) T
|
|
|
|
) T
|
|
|
|
LEFT JOIN tb_dept td
|
|
|
|
LEFT JOIN tb_dept td
|
|
|
|