I am trying to check time since first call was made to a customer. I am checking this against current system time using a case statement.
select sale_id,case when ((CURRENT_TIMESTAMP - min(call_date) >= '500 days' THEN 'more than 500 days'
when ((CURRENT_TIMESTAMP - min(call_date) >= '300 days' THEN 'more than 300 days'
else 'Less than 300 days' end as Aging
from sales
I keep getting Query execution failed. Invalid operation: syntax error at or neat "THEN".
I am using Amazon Redshift DB. Could anyone assist.
CURRENT_TIMESTAMP - min(call_date)is anintervaland'500 days'is valid literal for an interval - a_horse_with_no_name