Aggregate functions not allowed in WHERE clause

From: Ricardo Naranjo Faccini <gramo(dot)gnu(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Aggregate functions not allowed in WHERE clause
Date: 2006-06-13 02:00:33
Message-ID: 1150164033.17933.1.camel@dynamic-ip-6979134229.cable.net.co
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Cordially
--
@..@ Ricardo Naranjo Faccini Tel: (1) 257-9832
(----) Ingeniero Civil Calle 95 #30-61 int 8
( >__< ) M.Sc. Ing. de Sistemas y Comp. Barrio La Castellana
^^ ~~ ^^ gerencia(at)skinait(dot)com Bogotá D.C.
SKINA Colombia, S.A.
IT Solutions http://www.skinait.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2006-06-13 02:04:42 Re: Help with storing spatial (map coordinates) data?
Previous Message John Tregea 2006-06-13 01:27:07 Re: Help with storing spatial (map coordinates) data?