two sums in one query

Поиск
Список
Период
Сортировка
От Kenneth Gonsalves
Тема two sums in one query
Дата
Msg-id 200507081118.06628.lawgon@thenilgiris.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Make COUNT(*) Faster?
Следующее
От: Kenneth Gonsalves
Дата:
Сообщение: list admin note:Fwd: RE: two sums in one query