and wrt_user_nm like '%'||#{userNm}||'%'
and wrt_dt >= #{startDate}::date
and wrt_dt <= #{endDate}::date+1
and ab.affair_key in (
select affair_key
from affair_rating ar2
inner join organ_config oc2
on ar2.rating_organ = oc2.organ_cd
and ar2.affair_rate in
#{item}
and ar2.organ_up = 'T'
and oc2.organ_type in
#{item}
)
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'DC01')
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'DC02')
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'DC03')
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'DC04')
select item_cd as wrt_organ,
item_value,
coalesce(cnt,0) as cnt
from(
select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T'
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'OG' and use_chk = 'T')
order by item_cd asc) a left outer join
(select wrt_organ,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
and wrt_user_nm like '%'||#{userNm}||'%'
and wrt_dt >= #{startDate}::date
and wrt_dt <= #{endDate}::date+1
and ab.affair_key in (
select affair_key
from affair_rating ar2
inner join organ_config oc2
on ar2.rating_organ = oc2.organ_cd
and ar2.affair_rate in
#{item}
and ar2.organ_up = 'T'
and oc2.organ_type in
#{item}
)
and affair_type1 in
#{item}
and affair_type2 in
#{item}
and affair_type3 in
#{item}
and affair_type4 in
#{item}
group by wrt_organ)b on
a.item_cd = b.wrt_organ
order by wrt_organ asc
select b.item_cd as wrt_organ ,
b.item_value,
a.item_cd as affair_type,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'DC01'
)a left join
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T'
and item_cd in
#{item}
order by item_cd asc) b on 1=1
left outer join
(select wrt_organ,
affair_type1 as affair_type,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
group by wrt_organ,affair_type1) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc
select b.item_cd as wrt_organ ,
b.item_value,
a.item_cd as affair_type,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'DC02'
)a left join
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T'
and item_cd in
#{item}
order by item_cd asc) b on 1=1
left outer join
(select wrt_organ,
affair_type2 as affair_type,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
group by wrt_organ,affair_type2) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc
select b.item_cd as wrt_organ ,
b.item_value,
a.item_cd as affair_type,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'DC03'
)a left join
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T'
and item_cd in
#{item}
order by item_cd asc) b on 1=1
left outer join
(select wrt_organ,
affair_type3 as affair_type,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
group by wrt_organ,affair_type3) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc
select b.item_cd as wrt_organ ,
b.item_value,
a.item_cd as affair_type,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'DC04'
)a left join
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T'
and item_cd in
#{item}
order by item_cd asc) b on 1=1
left outer join
(select wrt_organ,
affair_type4 as affair_type,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
group by wrt_organ,affair_type4) c
on a.item_cd = c.affair_type and b.item_cd = c.wrt_organ
order by wrt_organ,affair_type asc
and wrt_user_nm like '%'||#{userNm}||'%'
and wrt_dt >= #{startDate}::date
and wrt_dt <= #{endDate}::date+1
and ab.affair_key in (
select affair_key
from affair_rating ar2
inner join organ_config oc2
on ar2.rating_organ = oc2.organ_cd
and ar2.affair_rate in
#{item}
and ar2.organ_up = 'T'
and oc2.organ_type in
#{item}
)
and affair_type1 in
#{item}
and affair_type2 in
#{item}
and affair_type3 in
#{item}
and affair_type4 in
#{item}
select item_cd as wrt_organ,
item_value,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T'
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'OG' and use_chk = 'T')
) a
left outer join
(select ab.wrt_organ,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
group by ab.wrt_organ) c
on a.item_cd = c.wrt_organ
order by item_cd asc
select item_cd as wrt_organ,
item_value,
b.organ_type as affairType,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T') a left join
(select organ_type
from organ_config
organ_type in
#{item}
organ_type not in (select organ_type from organ_config)
group by organ_type) b on 1=1
left outer join
(select ab.wrt_organ,
oc.organ_type,
count(*) as cnt
from affair_board ab,
affair_rating ar,
organ_config oc
where ab.affair_key = ar.affair_key
and ar.rating_organ = oc.organ_cd
and (ar.organ_up != 'T' or ar.organ_up is null)
group by ab.wrt_organ,oc.organ_type) c
on a.item_cd = c.wrt_organ and b.organ_type = c.organ_type
order by item_cd, affairType asc
select a.item_cd as wrt_organ,
b.item_cd as affairType,
coalesce(cnt,0) as cnt
from
(select item_cd,
item_value
from code_mgt
where category_cd = 'OG'
and use_chk = 'T') a left join
(select item_cd
from code_mgt
where category_cd='AAR'
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd='AAR')
) b on 1=1
left outer join
(select ab.wrt_organ,
ar.affair_rate,
count(*) as cnt
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and (ar.organ_up != 'T' or ar.organ_up is null)
group by ab.wrt_organ,ar.affair_rate) c
on c.wrt_organ = a.item_cd and c.affair_rate = b.item_cd
order by wrt_organ,affairType asc
and user_status = #{userStatus}
and user_status in ('USC003', 'USC007')
and user_nm like '%'||#{userNm}||'%'
and og_cd in
#{item}
and aa.wrt_dt >= #{startDate}::date
and aa.wrt_dt <= #{endDate}::date+1
and ab.affair_rate in
#{item}
and aa.affair_type1 in
#{item}
and aa.affair_type2 in
#{item}
and aa.affair_type3 in
#{item}
and aa.affair_type4 in
#{item}
and aa.affair_key in (
select aaa.affair_key
from affair_rating aaa
inner join organ_config aab
on aaa.rating_organ = aab.organ_cd
where aaa.organ_up = 'T'
and aab.organ_type in
#{item}
)
select user_status,
og_cd,
ofc_cd,
title_cd,
dic_code,
user_nm,
b.r1Cnt,
b.r2Cnt,
b.r3Cnt,
b.r4Cnt,
b.r5Cnt,
b.r6Cnt,
b.r7Cnt,
b.r8Cnt,
b.totalCnt
from user_info a
inner join
(
select aa.wrt_user_seq ,
sum(case when ab.affair_rate = 'AAR001' then 1 else 0 end) as r1Cnt,
sum(case when ab.affair_rate = 'AAR002' then 1 else 0 end) as r2Cnt,
sum(case when ab.affair_rate = 'AAR003' then 1 else 0 end) as r3Cnt,
sum(case when ab.affair_rate = 'AAR004' then 1 else 0 end) as r4Cnt,
sum(case when ab.affair_rate = 'AAR005' then 1 else 0 end) as r5Cnt,
sum(case when ab.affair_rate = 'AAR006' then 1 else 0 end) as r6Cnt,
sum(case when ab.affair_rate = 'AAR007' then 1 else 0 end) as r7Cnt,
sum(case when ab.affair_rate = 'AAR008' then 1 else 0 end) as r8Cnt,
count(*) as totalCnt
from affair_board aa
inner join affair_rating ab
on aa.affair_key = ab.affair_key and ab.affair_rate is not null and ab.organ_up = 'F'
group by aa.wrt_user_seq
) b on a.user_seq = b.wrt_user_seq
order by og_cd, ofc_cd, title_cd