Please help me write this query or function

From: Mr OCP <mr_ocp(at)yahoo(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Please help me write this query or function
Date: 2001-12-11 12:54:45
Message-ID: 20011211125445.96186.qmail@web20609.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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!

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Heather Johnson 2001-12-11 14:45:45 Re: problems doing sub-selects on PostgreSQL 7.1.3 and Solaris 7
Previous Message Genco Yilmaz 2001-12-11 10:27:11 shared library