pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mr OCP <mr_ocp@yahoo.com>
To: pgsql-admin@postgresql.org
Subject: Please help me write this query or function
Date: Tue, 11 Dec 2001 23:54:45 +1100 (EST)
Message-ID: <20011211125445.96186.qmail@web20609.mail.yahoo.com> (raw)

Hi

We have a table like follows:

id, account_name, amount, action_type

The amount field has both debit and credit entires and
action_type defines the type of transaction ( debit or
credit), debit entries have negative '-' symbol before
the amount.

where there are multipble transaction for the same id,
I need to write a query as under:

select id, amount(credit), amount(debit), amount
credit - amount debit from table where id is the same;

Its making it difficult for me because the amount
field has both debit and credit entries, your ideas,
codes or sql will be much appreciated.

Thanks
Mike

http://shopping.yahoo.com.au - Yahoo! Shopping
- Free CDs for thousands of Priority Shoppers!



view thread (2+ messages)  latest in thread

Message-ID: <20011211125445.96186.qmail@web20609.mail.yahoo.com>
Permalink:  ../20011211125445.96186.qmail@web20609.mail.yahoo.com/
Also on:    postgresql.org/message-id/20011211125445.96186.qmail@web20609.mail.yahoo.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mr_ocp@yahoo.com
  Subject: Re: Please help me write this query or function
  In-Reply-To: <20011211125445.96186.qmail@web20609.mail.yahoo.com>
  References: <20011211125445.96186.qmail@web20609.mail.yahoo.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