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@xxxxxxxxxxx Bogotá D.C. SKINA Colombia, S.A. IT Solutions http://www.skinait.com