Received: from hotmail.com (law-f90.hotmail.com [209.185.131.153]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f14LgJx21804; Sun, 4 Feb 2001 16:42:19 -0500 (EST) (envelope-from oomoomi@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 4 Feb 2001 13:42:16 -0800 Received: from 213.29.16.6 by lw1fd.hotmail.msn.com with HTTP; Sun, 04 Feb 2001 21:42:16 GMT X-Originating-IP: [213.29.16.6] From: "omid omoomi" To: pgsql-general@postgresql.org Cc: pgsql-sql@postgresql.org Subject: Aggregates and joined tables... Date: Sun, 04 Feb 2001 21:42:16 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 04 Feb 2001 21:42:16.0524 (UTC) FILETIME=[57A8A0C0:01C08EF3] X-Archive-Number: 200102/110 X-Sequence-Number: 3943 Hi all, I have a problem using aggregate function SUM() ... The platform is PostgreSQL 6.5.2 on i386-unknown-freebsd3.2, compiled by gcc 2.7.2.1 . The story is that I need to join two tables with an aggregate function. Here is a sample model : Table A consist of ( fa1 , fa2 ) Table B consist of ( fb1 , fb2 ) Table C consist of ( fc1 , fc2 ,fc3 ) I want to write a query which looks like this : select fa1 - sum(fc3) from A,B,C where fa1=fb1 and fb2=fc2 group by fa1 ; unfortunately I get this in result: ERROR: Illegal use of aggregates or non-group column in target list Any idea ? How can I have my result with only one SQL statement ? Thanks in advance Omid Omoomi _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.