Search Postgresql Archives

Re: count case when - PG 9.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2017-03-10 10:17 GMT+13:00 Yasin Sari <yasinsari81@xxxxxxxxxxxxxx>:
if you want see account_status and the count()- try this:

SELECT
CASE
        WHEN 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,
        count(*)
    FROM public.clients c
        WHERE (
               (last_pay > EXTRACT('epoch' FROM now() - '12 Months'::INTERVAL))
              ) 
               group by 1 
    ORDER BY 1 



Thanks Yasin! That worked.

P.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux