I need to select the three month names, from previous quarter, and apply those month names in my where statement. I can't get the following to work:
WHERE table.column in
(CASE WHEN to_char(sysdate, 'MM') in (01,02,03) THEN ('OCTOBER','NOVEMBER','DECEMBER')
WHEN to_char(sysdate, 'MM') in (04,05,06) THEN ('JANUARY','FEBRUARY','MARCH')
WHEN to_char(sysdate, 'MM') in (07,08,09) THEN ('APRIL','MAY','JUNE')
WHEN to_char(sysdate, 'MM') in (10,11,12) THEN ('JULY', 'AUGUST', 'SEPTEMBER')
END)
You can't return multiple results from a
caseexpression. But you can do:Note I've also explicitly converted the numbers to strings, that's because
to_charwill be returning a string too, you want to avoid implicit conversion.DEMO