On Sun, Jan 31, 2021 at 1:01 AM Carlos Sotto Maior (UOL)
<csotto(at)uol(dot)com(dot)br> wrote:
>
> Thanks a lot Tom.
> I'll solve it with a subquery.
No need for a subquery. In your particular case, it should just work with:
SELECT count(*) as cnt, f1, f2, active
FROM public.z_having
GROUP BY f1, f2, active
HAVING active = True AND count(*) > 1
ORDER BY cnt DESC
It can get ugly if your aggregates are large and complex, but not for
a simple count(*)...
//Magnus