On Mon, Jun 12, 2006 at 08:40:29PM -0700, pradeep singh wrote:
> i think this query can be rewritten as
>
> SELECT claim_id,sum(invoices),sum(payments)
> FROM logs
> GROUP BY claim_id
> HAVING sum(invoices) > 0 OR sum(payments) > 0;
>
> having clause can be used with aggregate functions but
>
i think this query can be rewritten as
SELECT claim_id,sum(invoices),sum(payments)
FROM logs
GROUP BY claim_id
HAVING sum(invoices) > 0 OR sum(payments) > 0;
having clause can be used with aggregate functions but
those functions should be the part of column
list/expression list in the SELECT
Quoth [EMAIL PROTECTED] (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
> WHER
On Mon, Jun 12, 2006 at 09:00:33PM -0500, Ricardo Naranjo Faccini wrote:
> 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"
I think you're look
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
)
GR