select * from
(
select
'1번' name
,1 as a
, case when clo_cd is not null then 2 else 0 end as b
, case when id = 'ACT' then 3 else 0 end as c
, case when tas not in ('698','703') then 4 else 0 end as d
, case when dttm < to_char(sysdate,yyyymmdd) then 5 else 0 end as e
from aaa
union all
select
'2번' name
,1 as a
, case when clo_cd is not null then 2 else 0 end as b
, case when id = 'ACT' then 3 else 0 end as c
, case when tas not in ('698','703') then 4 else 0 end as d
, case when dttm < to_char(sysdate,yyyymmdd) then 5 else 0 end as e
from bbb
)
where 1=1
and name = '1번'
and 'a' = '1'
조건절은 and name=?
and ? = ?
이렇게 되어있습니다 저런게 많이 2번이상 반복되서 그 원하는 이름과 end 네임으로 각각 맞는걸 하나씩 뽑으려고하는게 최종목표인데
and a = '1' 이렇게되야하는데 a도 값을 파라메터로 넘기다보니 'a' 들어가는거같습니다 ㅠ 쉽게 해결방법없을까요?
쿼리자체가 잘못되어진거같기도하고 어렵네요