I have the following SQL query where the CASE statement needs to return multiple values.
select TASK_NAME
from TASK
where TASK_TYPE in (
case
when (select USER_COUNTRY from USER) in (select COUNTRY_NAME from COUNTRY where CONTINENT = 'Europe') then ('Adhoc', 'Resell')
when (select USER_COUNTRY from USER) in (select COUNTRY_NAME from COUNTRY where CONTINENT = 'Americas') then ('Classified', 'Bought', 'Handle')
else ('None', 'Blank')
end )
However, the number of WHEN clauses is not fixed as there may be more conditions. I don't think SQL return multiple values from CASE statement will work.
I should also add that grouping is not recognised by the application which this query is passed to.
I apologise for not providing the tables. I will do so in due course. Just wanted to get this out there.