From: | Patrick B <patrickbakerbr(at)gmail(dot)com> |
---|---|
To: | Yasin Sari <yasinsari81(at)googlemail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org>, pgsql-general-owner(at)postgresql(dot)org |
Subject: | Re: count case when - PG 9.2 |
Date: | 2017-03-09 21:19:22 |
Message-ID: | CAJNY3isxNYTgcgF_Xp2mrPvVtr4nKqwSGCyAfcVyzuH6jb=Lnw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2017-03-10 10:17 GMT+13:00 Yasin Sari <yasinsari81(at)googlemail(dot)com>:
> 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,
>
> c <http://c.id/>ount(*)
>
> 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2017-03-09 21:37:28 | Re: Unable to start postgresql |
Previous Message | Adrian Klaver | 2017-03-09 21:18:28 | Re: Unable to start postgresql |