É possível de alguma forma fazer isso?
WITH T1 AS
(
SELECT 1 AS SEQ, 'NOTHING 1' AS SOME_TYPE FROM DUAL UNION ALL
SELECT 2 AS SEQ, 'NOTHING 2' AS SOME_TYPE FROM DUAL UNION ALL
SELECT 3 AS SEQ, 'SOMETHING 1' AS SOME_TYPE FROM DUAL UNION ALL
SELECT 4 AS SEQ, 'SOMETHING 2' AS SOME_TYPE FROM DUAL UNION ALL
SELECT 5 AS SEQ, 'SOMETHING 3' AS SOME_TYPE FROM DUAL UNION ALL
select 6 as seq, 'SOMETHING 4' AS SOME_TYPE from dual
)
, T2 AS
(
SELECT 'A' AS COMPARE_TYPE FROM DUAL UNION ALL
SELECT 'B' AS COMPARE_TYPE FROM DUAL
)
SELECT T2.*, T1.*
FROM T1, T2
WHERE CASE T2.COMPARE_TYPE
WHEN 'A'
THEN T1.SOME_TYPE LIKE 'NOTHING%'
ELSE T1.SOME_TYPE NOT LIKE 'NOTHING%'
END
Eu sei que minha cláusula WHERE is não está correta.
Qualquer ajuda seria ótima para saber se esse tipo de declaração é possível.
Eu não quero escrever um SQL dinâmico. Se for preciso, escreverei 2 instruções SQL diferentes.
Obrigado