pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kenneth Gonsalves <lawgon@thenilgiris.com>
To: pgsql-sql@postgresql.org
Subject: two sums in one query
Date: Fri, 8 Jul 2005 11:18:06 +0530
Message-ID: <200507081118.06628.lawgon@thenilgiris.com> (raw)

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
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!



view thread (7+ messages)  latest in thread

Message-ID: <200507081118.06628.lawgon@thenilgiris.com>
Permalink:  ../200507081118.06628.lawgon@thenilgiris.com/
Also on:    postgresql.org/message-id/200507081118.06628.lawgon@thenilgiris.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lawgon@thenilgiris.com
  Subject: Re: two sums in one query
  In-Reply-To: <200507081118.06628.lawgon@thenilgiris.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox