Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin

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.

Mike - Yahoo! Shopping
- Free CDs for thousands of Priority Shoppers!


pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group