Quoth gramo.gnu@gmail.com (Ricardo Naranjo Faccini):
> I have two tables, Claims and Logs, and I need to fish in for the id of
> any
> claim who have into the logs anything into the fields invoices or
> payments
>
> I think the best way to do this is by mean of:
>
> SELECT claim_id
> FROM logs
> WHERE (
> sum(logs.invoices) > 0
> OR
> sum(logs.payments) > 0
> )
> GROUP BY claim_id
>
> But Postgres claims "Aggregate functions not allowed in WHERE clause"
>
> Anyone could help me to figure out this task please
You might consider using a HAVING clause to add those constraints at
the grouping level...
select claim_id
from logs
group by claim_id
having sum(logs.invoices) > 0 or sum(logs.payments) > 0;
You might need to have those sums in the outer select...
--
(reverse (concatenate 'string "ofni.secnanifxunil" "@" "enworbbc"))
http://linuxfinances.info/info/finances.html
"Microsoft has world class quality control" -- Arthur Norman