X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9273F529F4 for ; Fri, 8 Jul 2005 02:48:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26591-09 for ; Fri, 8 Jul 2005 05:47:55 +0000 (GMT) Received: from sharp.noc24x7.com (unknown [69.56.128.138]) by svr1.postgresql.org (Postfix) with ESMTP id 456F752AA4 for ; Fri, 8 Jul 2005 02:47:54 -0300 (ADT) Received: from [61.3.110.136] (helo=thenilgiris.web) by sharp.noc24x7.com with esmtp (Exim 4.50) id 1DqliN-0007hn-FV for pgsql-sql@postgresql.org; Fri, 08 Jul 2005 11:17:56 +0530 Received: by thenilgiris.web (Postfix, from userid 500) id 84A925B91C; Fri, 8 Jul 2005 11:18:07 +0530 (IST) From: Kenneth Gonsalves To: Subject: two sums in one query Date: Fri, 8 Jul 2005 11:18:06 +0530 User-Agent: KMail/1.6.1 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <200507081118.06628.lawgon@thenilgiris.com> X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - sharp.noc24x7.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - thenilgiris.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.072 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/60 X-Sequence-Number: 22038 hi i have a table like this: serialno varchar, debit integer, credit integer, amount numeric the columns 'debit' and 'credit' refer to the acount number. I want to=20 query the table to select all the rows where either debit =3D account=20 or credit=3Daccount and to get two sums - one of the amounts where the=20 account is on the debit side and the other on the credit side. Can i=20 do this in one query? if so, how? =2D-=20 regards kg http://www.livejournal.com/users/lawgon tally ho! http://avsap.org.in =E0=B2=87=E0=B2=82=E0=B2=A1=E0=B3=8D=E0=B2=B2=E0=B2=BF=E0=B2=A8=E0=B2=95=E0= =B3=8D=E0=B2=B8 =E0=AE=B5=E0=AE=BE=E0=AE=B4=E0=AF=8D=E0=AE=95!