вот как я "взломал" его:
select x.now, count(x.status) as total
from
(
select now(), date_trunc('month', now()) as start_of_month, now() -
interval '1 month' as last_month
, date_trunc('month', now() - interval '1 month') as
start_of_last_month, status
, created_date
from my_table
)x
where x.created_date between x.start_of_month and x.now
group by x.now
UNION ALL
select x.last_month, count(x.status) as total
from
(
select now(), date_trunc('month', now()) as start_of_month, now() -
interval '1 month' as last_month
, date_trunc('month', now() - interval '1 month') as
start_of_last_month, status
, created_date
from my_table
)x
where x.created_date between x.start_of_last_month and x.last_month
group by x.last_month
Используя "UNION ALL" Я заменил "x.now" на «x.last_month» в выбранном и в предложении where временной интервал даты предложения, так что теперь у меня есть текущий месяц (где бы я ни находился в этом месяце) и то же самое для предыдущего месяца