Postgres Aggregate Functions Boolean Logic