and a.affair_category = #{affairCategory}
and a.wrt_user_seq = #{wrtUserSeq}
and a.wrt_user_nm like '%'||#{wrtUserNm}||'%'
and a.wrt_organ = #{wrtOrgan}
and a.affair_type1 = #{affairType1}
and a.affair_type2 = #{affairType2}
and a.affair_type3 = #{affairType3}
and a.affair_type4 = #{affairType4}
and a.title like '%'||#{title}||'%'
and c.affair_status = #{affairStatus}
and a.wrt_dt >= #{startDate}::date
and a.wrt_dt <= #{endDate}::date+1
and c.rating_organ = #{ratingOrgan}
and a.wrt_organ in
#{organCd}
and c.affair_status in ('DST002', 'DST004')
and c.affair_status in ('DST003', 'DST005', 'DST006')
and c.affair_status in ('DST003', 'DST004', 'DST005', 'DST006')
and c.affair_status in ('DST003', 'DST005', 'DST006')
and c.affair_status in ('DST002', 'DST004')
and c.affair_status in ('DST003', 'DST005', 'DST006')
select a.affair_key,
a.affair_type1,
a.affair_type2,
a.affair_type3,
a.affair_type4,
a.title,
a.wrt_organ,
a.wrt_part,
a.wrt_user_nm,
a.wrt_user_seq,
a.wrt_dt,
b.fileCnt,
c.affair_status,
c.affair_rate,
c.organ_up
from affair_board a
left outer join (select affair_key,
count(file_seq) as fileCnt
from affair_file
group by affair_key) b
on a.affair_key = b.affair_key
inner join affair_rating c
on a.affair_key = c.affair_key
order by a.affair_key desc
limit #{rowCnt} offset #{firstIndex}
select count(*)
from affair_board a
inner join affair_rating c
on a.affair_key = c.affair_key
select aa.hashTags
from (select a.affair_key,
array_to_string(array_agg(b.tag_nm), ' ') as hashTags
from hash_tag_link a
inner join hash_tag b on a.tag_key = b.tag_key
where a.affair_key = #{affairKey}
group by a.affair_key) aa
select item_cd as affairType,
item_value
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 = 'DC01')
order by affairType asc
select item_cd as affairType,
item_value
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 = 'DC02')
order by affairType asc
select item_cd as affairType,
item_value
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 = 'DC03')
order by affairType asc
select item_cd as affairType,
item_value
from code_mgt
where category_cd = 'DC04'
and item_cd in
#{item}
and item_cd not in (select item_cd from code_mgt where category_cd = 'DC04')
order by affairType asc
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
or affair_type1 in
#{item}
or affair_type2 in
#{item}
or affair_type3 in
#{item}
or 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'
and item_cd in
#{item}
and item_cd not in (select item_cd 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
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'
and item_cd in
#{item}
and item_cd not in (select item_cd 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
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'
and item_cd in
#{item}
and item_cd not in (select item_cd 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
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'
and item_cd in
#{item}
and item_cd not in (select item_cd 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
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