Case statement in where clause
- SELECT T2.*, T1.*
- FROM T1, T2
- WHERE (CASE WHEN T2.COMPARE_TYPE = 'A' AND
- T1.SOME_TYPE LIKE 'NOTHING%'
- THEN 1
- WHEN T2.COMPARE_TYPE != 'A' AND
- T1.SOME_TYPE NOT LIKE 'NOTHING%'
- THEN 1
- ELSE 0
- END) = 1
Result
C SEQ SOME_TYPE
- ---------- -----------
A 1 NOTHING 1
A 2 NOTHING 2
B 3 SOMETHING 1
B 4 SOMETHING 2
B 5 SOMETHING 3
B 6 SOMETHING 4
No comments:
Post a Comment