260603_01_ENH: 예측실에서 사용하는 유용한 쿼리 첨부
This commit is contained in:
54
src/main/resources/util-query/예측실 유용 쿼리.sql
Normal file
54
src/main/resources/util-query/예측실 유용 쿼리.sql
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*******************************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>*************************************/
|
||||||
|
declare @time_band as int
|
||||||
|
set @time_band = 5
|
||||||
|
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>*************************/
|
||||||
|
select *
|
||||||
|
from F_time
|
||||||
|
where close_flag = 0
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>*************************/
|
||||||
|
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ϸ<EFBFBD>*************************/
|
||||||
|
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
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ϸ<EFBFBD>*************************/
|
||||||
|
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20>ȴ<EFBFBD><C8B4><EFBFBD> <20><>ǥ<EFBFBD><C7A5>*************************/
|
||||||
|
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
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20>ȴ<EFBFBD><C8B4><EFBFBD> <20><>ǥ<EFBFBD><C7A5>*************************/
|
||||||
|
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20>ȴ<EFBFBD><C8B4><EFBFBD> <20><><EFBFBD><EFBFBD>*************************/
|
||||||
|
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
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20>ȴ<EFBFBD><C8B4><EFBFBD> <20><><EFBFBD><EFBFBD>*************************/
|
||||||
|
|
||||||
|
/********************0<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20><>ǥ<EFBFBD><C7A5>*************************/
|
||||||
|
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<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20><>ǥ<EFBFBD><C7A5>*************************/
|
||||||
|
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD>Һ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*************************/
|
||||||
|
select e_full_it as [<EFBFBD><EFBFBD>ǥ<EFBFBD><EFBFBD> <EFBFBD>ڵ<EFBFBD>], e_exit_nm as [<EFBFBD><EFBFBD>ǥ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>], vcnt as [<EFBFBD><EFBFBD>ǥ<EFBFBD><EFBFBD>], refuse as [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>], case when vcnt = 0 then 0 else (cast(refuse as decimal) * 100) /vcnt end as [<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>]
|
||||||
|
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
|
||||||
|
/********************<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD>Һ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*************************/
|
||||||
Reference in New Issue
Block a user