Hi guys. How can I count using 'CASE WHEN'?
Example:
I wanna know how many of 'trial' and 'paying' customers the query returns. can you guys please advice how to do it?SELECTCASEWHEN AND c.regdate > EXTRACT(epoch FROM (now() - INTERVAL '14 day'))THEN 'trial'WHEN last_pay > EXTRACT(epoch FROM (now() - INTERVAL '37 day'))THEN 'paying'END as account_status,FROM public.clients cWHERE ((last_pay > EXTRACT('epoch' FROM now() - '12 Months'::INTERVAL)))ORDER BY 1
Thanks
Patrick