two sums in one query

From: Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: two sums in one query
Date: 2005-07-08 05:48:06
Message-ID: 200507081118.06628.lawgon@thenilgiris.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
query the table to select all the rows where either debit = account
or credit=account and to get two sums - one of the amounts where the
account is on the debit side and the other on the credit side. Can i
do this in one query? if so, how?
--
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Browse pgsql-sql by date

  From Date Subject
Next Message Kenneth Gonsalves 2005-07-08 05:56:50 list admin note:Fwd: RE: two sums in one query
Previous Message Tom Lane 2005-07-08 04:27:23 Re: Make COUNT(*) Faster?