Hi All:
I want to write a query to conditionally set the values passed to an IN operator. Using the code below, I want to pass ('A', 'B') when someVariable = 'someVal'. Else I pass ('C', 'D', 'E'). Whatever I pass should filter the cur_data table on the key_letter column.
Any thoughts how to do this?
TIA,
Sven
SELECT colA FROM cur_data
WHERE key_letter IN
(CASE WHEN someVariable = 'someVal'
THEN ('A', 'B')
ELSE ('C', 'D', 'E')
END)
I want to write a query to conditionally set the values passed to an IN operator. Using the code below, I want to pass ('A', 'B') when someVariable = 'someVal'. Else I pass ('C', 'D', 'E'). Whatever I pass should filter the cur_data table on the key_letter column.
Any thoughts how to do this?
TIA,
Sven
SELECT colA FROM cur_data
WHERE key_letter IN
(CASE WHEN someVariable = 'someVal'
THEN ('A', 'B')
ELSE ('C', 'D', 'E')
END)