From 42bb0a5c7399a72cac00f8be5581cc3f7a529e2b Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 3 Jun 2026 17:17:49 +0900 Subject: [PATCH] =?UTF-8?q?260603=5F01=5FENH:=20=EC=98=88=EC=B8=A1?= =?UTF-8?q?=EC=8B=A4=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=9C=A0=EC=9A=A9=ED=95=9C=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?=EC=B2=A8=EB=B6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/util-query/예측실 유용 쿼리.sql | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/resources/util-query/예측실 유용 쿼리.sql diff --git a/src/main/resources/util-query/예측실 유용 쿼리.sql b/src/main/resources/util-query/예측실 유용 쿼리.sql new file mode 100644 index 0000000..fa6e868 --- /dev/null +++ b/src/main/resources/util-query/예측실 유용 쿼리.sql @@ -0,0 +1,54 @@ +/*******************************¿¹Ãø½Ç À¯¿ë Äõ¸®*************************************/ +declare @time_band as int +set @time_band = 5 + +/********************¿­¸° Â÷¼ö*************************/ +select * +from F_time +where close_flag = 0 +/********************¿­¸° Â÷¼ö*************************/ + +/********************Â÷¼öº° ¿Ï·á*************************/ +select a.time_band, a.start_time, a.title, count(b.subarea_cd) as cnt +from F_time a with(nolock) +left join F_exitPoll b with(nolock) on a.time_band=b.time_band +where a.time_band != 0 and a.time_band <= @time_band +group by a.time_band, a.start_time, a.title +/********************Â÷¼öº° ¿Ï·á*************************/ + +/********************Áý°è¿Ï·á ¾È´©¸¥ ÅõÇ¥¼Ò*************************/ +select a.e_full_it, a.e_exit_nm, count(b.subarea_cd) as paper_cnt +FROM R_Exit a with(nolock) +left join F_exitPoll b with(nolock) on a.e_full_it = b.subarea_cd and b.time_band = @time_band +where e_full_it not in (select distinct subarea_cd from [exitpoll].[dbo].[F_EXITPOLL_REPORT] where [time_band] in ( @time_band)) +group by a.e_full_it, a.e_exit_nm +/********************Áý°è¿Ï·á ¾È´©¸¥ ÅõÇ¥¼Ò*************************/ + +/********************Áý°è¿Ï·á ¾È´©¸¥ Áö¿ª*************************/ +select a.e_subarea_cd, a.e_subarea_nm, count(a.e_full_it) as cnt +, (select count(1) from F_exitPoll where area_cd=a.e_subarea_cd and time_band = @time_band)as paper_cnt +FROM R_Exit a with(nolock) +where e_full_it not in (select distinct subarea_cd from [exitpoll].[dbo].[F_EXITPOLL_REPORT] where [time_band] in ( @time_band)) +group by a.e_subarea_cd, a.e_subarea_nm +/********************Áý°è¿Ï·á ¾È´©¸¥ Áö¿ª*************************/ + +/********************0°Ç Áý°è¿Ï·á ÅõÇ¥¼Ò*************************/ +select b.e_full_it, b.e_exit_nm, count(a.subarea_cd) as cnt, max(c.confirm_flag) as cf +FROM R_Exit b with(nolock) +left join F_exitPoll a with(nolock) on a.subarea_cd = b.e_full_it and a.time_band = @time_band +left join [F_EXITPOLL_REPORT] c with(nolock) on b.e_full_it = c.subarea_cd and C.time_band = @time_band +group by b.e_full_it, b.e_exit_nm +having count(a.subarea_cd) = 0 and max(c.confirm_flag) = 1 +/********************0°Ç Áý°è¿Ï·á ÅõÇ¥¼Ò*************************/ + +/********************Â÷¼öº° ÅõÇ¥¼Òº° °ÅÀýÀ²*************************/ +select e_full_it as [ÅõÇ¥¼Ò ÄÚµå], e_exit_nm as [ÅõÇ¥¼Ò ¸í], vcnt as [ÅõÇ¥¼ö], refuse as [°ÅÀý¼ö], case when vcnt = 0 then 0 else (cast(refuse as decimal) * 100) /vcnt end as [°ÅÀý ºñÀ²] +from ( + select b.e_full_it, b.e_exit_nm, count(a.subarea_cd) as vcnt, sum(case when a.cand_cd = '00' then 1 else 0 end) as refuse + from R_Exit b with(nolock) + left join F_exitPoll a with(nolock) on a.subarea_cd = b.e_full_it and a.time_band = @time_band + group by b.e_full_it, b.e_exit_nm +) out_a +where 1=1 +order by e_full_it +/********************Â÷¼öº° ÅõÇ¥¼Òº° °ÅÀýÀ²*************************/ \ No newline at end of file