Untitled

mail@pastecode.io avatar
unknown
pgsql
a year ago
345 B
3
Indexable
Never
select
       sum(case when date_trunc('day', now()) = date_trunc('day', paid_at) then amount else 0 end),
       sum(case when date_trunc('week', now()) = date_trunc('week', paid_at) then amount else 0 end),
       sum(case when date_trunc('month', now()) = date_trunc('month', paid_at) then amount else 0 end),
       sum(amount)
from payments