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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Please help me write this query or function



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!



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group