Please help me write this query or function - Mailing list pgsql-admin

From Mr OCP
Subject Please help me write this query or function
Date
Msg-id 20011211125445.96186.qmail@web20609.mail.yahoo.com
Whole thread Raw
Responses Re: Please help me write this query or function  (Masaru Sugawara <rk73@echna.ne.jp>)
List 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!

pgsql-admin by date:

Previous
From: Chao Lu
Date:
Subject: the results of pgbench are not stable (in tps)
Next
From: bpalmer
Date:
Subject: Re: problems doing sub-selects on PostgreSQL 7.1.3 and