Re: [GENERAL] Aggregate functions not allowed in WHERE clause

2006-06-13 Thread Michael Fuhr
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 >

Re: [GENERAL] Aggregate functions not allowed in WHERE clause

2006-06-12 Thread pradeep singh
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

Re: [GENERAL] Aggregate functions not allowed in WHERE clause

2006-06-12 Thread Christopher Browne
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

Re: [GENERAL] Aggregate functions not allowed in WHERE clause

2006-06-12 Thread Michael Fuhr
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

[GENERAL] Aggregate functions not allowed in WHERE clause

2006-06-12 Thread 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 ) GR