where 1=1
and
case when '${orgtype}'='002' and '${gpk_orgtype}'='002' then
(case when '${orgid}'='1' and '${gpk_orgid}'='1' then '1' else ct.revise_org_id end)
when '${orgtype}'='003' and '${gpk_orgtype}'='003' then
(case when '${orgid}'='1' and '${gpk_orgid}'='1' then '1' else ta.trans_org end)
else (case when '${orgid}'='1' and '${gpk_orgid}'='1' then '1' else ta.complained_company1 end) end
=
case when '${orgid}'='1' and '${gpk_orgid}'='1' then '1' else '${orgid}' end