Hello,
I need help with CASE statement that refers to a date column. I am using the following CASE statement to generate output column Number_of_days which based on the received_timstm column shows all the ID's which have no entry in either past 5/10/15/ More than 15 days.
select distinct ID, to_timestamp(RECEIVED_TIMSTM),
case
when trunc(sysdate) -trunc(received_timstm) >= 5 and trunc(sysdate) -trunc(received_timstm) <=10 THEN '10_days'
when trunc(sysdate) -trunc(received_timstm) >= 10 and trunc(sysdate) -trunc(received_timstm) <=15 THEN '15_days'
when trunc(sysdate) -trunc(received_timstm) > 15 THEN 'More_15_days'
ELSE NULL END AS Number_of_days
from table_name;
However, this does not seem to work.
Any help is appreciated.
Thank you so much!