a.status <> 'DST008'
and ((a.wrt_user_seq = #{wrtUserSeq} and a.status = 'DST002') or a.status = 'DST007')
and a.work_rating = #{workRating}
and a.arrest_type1 = #{arrestType1}
and a.arrest_type2 = #{arrestType2}
and a.title like '%'||#{title}||'%'
and a.wrt_user_nm like '%'||#{wrtUserNm}||'%'
and a.wrt_organ = #{wrtOrgan}
and a.ciw_key in (
select aa.ciw_key
from hash_tag_link_ciw aa
inner join hash_tag ab on aa.tag_key = ab.tag_key
where ab.tag_nm like '%'||#{hashTags}||'%'
)
and a.work_start_date >= #{startDate}::date
and a.work_start_date <= #{endDate}::date+1
and a.work_end_date >= #{startDate}::date
and a.work_end_date <= #{endDate}::date+1
and a.re_rating_date1 >= #{startDate}::date
and a.re_rating_date1 <= #{endDate}::date+1
and a.re_rating_date2 >= #{startDate}::date
and a.re_rating_date2 <= #{endDate}::date+1
and a.wrt_dt >= #{startDate}::date
and a.wrt_dt <= #{endDate}::date+1
select a.ciw_key,
a.status,
a.work_rating,
a.work_start_date,
a.work_end_date,
a.re_rating_date1,
a.re_rating_date2,
a.arrest_type1,
a.arrest_type2,
a.title,
a.wrt_organ,
a.wrt_part,
a.wrt_user_seq,
a.wrt_user_grd,
a.wrt_user_nm,
a.wrt_dt,
b.fileCnt
from counter_intelligence_work a
left outer join (select ciw_key, count(*) as fileCnt from ciw_file group by ciw_key) b
on a.ciw_key = b.ciw_key
ORDER BY a.ciw_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
select count(*)
from counter_intelligence_work a
left outer join (select ciw_key, count(*) as fileCnt from ciw_file group by ciw_key) b
on a.ciw_key = b.ciw_key
select array_to_string(array_agg(b.tag_nm), ' ') as hashTags
from hash_tag_link_ciw a
inner join hash_tag b on a.tag_key = b.tag_key
where a.ciw_key = #{ciwKey}
select work_rating,
count(case when work_start_date > (#{year}||'-01-01')::date and work_start_date < (#{year}+1||'-01-01')::date then 1 end) as newWorkCnt,
count(case when work_end_date > (#{year}+1||'-01-01')::date and work_end_date < (#{year}+2||'-01-01')::date then 1 end) as doingWorkCnt,
count(case when work_start_date > (#{year}-1||'-01-01')::date and work_start_date < (#{year}||'-01-01')::date and work_end_date > (#{year}||'-01-01')::date and work_end_date < (#{year}+1||'-01-01')::date then 1 end) as prevYearWorkEndCnt,
count(case when work_start_date > (#{year}||'-01-01')::date and work_start_date < (#{year}+1||'-01-01')::date and work_end_date > (#{year}||'-01-01')::date and work_end_date < (#{year}+1||'-01-01')::date then 1 end) as thisYearWorkEndCnt
from counter_intelligence_work a
WHERE a.status = 'DST007'
group by work_rating
order by work_rating
select year
from ( select EXTRACT(YEAR FROM work_start_date) AS year
from counter_intelligence_work
where status <> 'DST008'
union
select EXTRACT(YEAR FROM now()) AS year
) a
group by year
order by year desc
select cia.ci_key,
cia.ci_type,
(select item_value from code_mgt where item_cd = cia.wrt_organ) as wrt_organ,
sdi.local_info,
sdi.outlook_problem,
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
safty_demand_info sdi
where cia.ci_key = sdi.ci_key
and cia.wrt_organ in
#{item}
ORDER BY cia.ci_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
select count(*)
from(
select cia.ci_key,
cia.ci_type,
(select item_value from code_mgt where item_cd = cia.wrt_organ) as wrt_organ,
sdi.local_info,
sdi.outlook_problem,
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
safty_demand_info sdi
where cia.ci_key = sdi.ci_key
and cia.wrt_organ in
#{item}
ORDER BY cia.ci_key DESC
)a
select cia.ci_key,
cia.ci_type,
(select item_value from code_mgt where item_cd = mci.mgt_organ) as mgt_organ,
mci.company_nm,
mci.company_location,
mci.related_field,
mci.description,
mci.cell_phone,
mci.department,
mci."name",
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
manage_company_info mci
where cia.ci_key = mci.ci_key
and mci.mgt_organ in
#{item}
ORDER BY cia.ci_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
select count(*)
from(
select cia.ci_key,
cia.ci_type,
(select item_value from code_mgt where item_cd = mci.mgt_organ) as mgt_organ,
mci.company_nm,
mci.company_location,
mci.related_field,
mci.description,
mci.cell_phone,
mci.department,
mci."name",
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
manage_company_info mci
where cia.ci_key = mci.ci_key
and mci.mgt_organ in
#{item}
ORDER BY cia.ci_key DESC
)a
select cia.ci_key,
(select item_value from code_mgt where item_cd = fi.mgt_organ) as mgt_organ,
fi.manager,
fi.commu_location,
fi.commu_national,
fi.commu_address,
fi.select_reason,
fi.monitoring_info,
fi.fix_date,
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
foreigner_info fi
where cia.ci_key = fi.ci_key
and fi.mgt_organ in
#{item}
ORDER BY cia.ci_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
select count(*)
from(
select cia.ci_key,
(select item_value from code_mgt where item_cd = fi.mgt_organ) as mgt_organ,
fi.manager,
fi.commu_location,
fi.commu_national,
fi.commu_address,
fi.select_reason,
fi.monitoring_info,
fi.fix_date,
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
foreigner_info fi
where cia.ci_key = fi.ci_key
and fi.mgt_organ in
#{item}
ORDER BY cia.ci_key DESC
)a
select cia.ci_key,
(select item_value from code_mgt where item_cd = ei.mgt_organ) as mgt_organ,
ei.edu_date,
ei.edu_type,
ei.people_cnt,
ei.description,
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
edu_info ei
where cia.ci_key = ei.ci_key
and ei.mgt_organ in
#{item}
ORDER BY cia.ci_key DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
select count(*)
from(
select cia.ci_key,
(select item_value from code_mgt where item_cd = ei.mgt_organ) as mgt_organ,
ei.edu_date,
ei.edu_type,
ei.people_cnt,
ei.description,
(select item_value from code_mgt where item_cd = cia.wrt_user_grd) as wrt_user_grd,
cia.wrt_user_nm,
cia.wrt_dt
from counter_intelligence_activity cia,
edu_info ei
where cia.ci_key = ei.ci_key
and ei.mgt_organ in
#{item}
ORDER BY cia.ci_key DESC
)a