有可能以某种方式做到这一点吗?
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
我知道我的 WHERE is 子句不正确。
任何帮助都有助于了解这种类型的陈述是否可行。
我不想编写动态 SQL。如果必须,我将编写 2 条不同的 SQL 语句。
谢谢