two sums in one query - Mailing list pgsql-sql

From Kenneth Gonsalves
Subject two sums in one query
Date
Msg-id 200507081118.06628.lawgon@thenilgiris.com
Whole thread Raw
List 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
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Make COUNT(*) Faster?
Next
From: Kenneth Gonsalves
Date:
Subject: list admin note:Fwd: RE: two sums in one query