I want to filter in subquery with aliased field from main query:
select a.created_at::date as creation_date, a.field as field,
(select count(*)
from table b
where a.field = b.field
and a.created_at::date = b.created_at::date) as count_one
from table a
group by creation_date, field;
but this gives error
ERROR: subquery uses ungrouped column "a.created_at" from outer query
Any options how to solve it?