BassettProvidentia
New member
- Local time
- Today, 22:52
- Joined
- Feb 25, 2011
- Messages
- 5
Splitting "sum" column into two columns, depending on value of another colum
Hi,
I have a "posting" table that contains records relating to single transactions in a double ended bookkeeping system. Each real world transaction has two postings, a positive one, and a negative one.
Buying a car:
£20,000 "credit" posting against the account "purchases"
£20,000 "debit" posting against the account "motor vehicles"
My posting table looks like this:
posting_id - int, primary key
account_id - in, foreign key
date - timestamp
sum - decimal
type - either "credit" or "debit"
I need to have a query where all postings will be listed, with each "credit" posting in one column and each "debit" in another. Each "credit" posting will have a NULL value in the "debit" column, and vice versa.
I have tried using an union query. As this seems like quite a common problem, does anyone have any suggestions?
Thanks!
Hi,
I have a "posting" table that contains records relating to single transactions in a double ended bookkeeping system. Each real world transaction has two postings, a positive one, and a negative one.
Buying a car:
£20,000 "credit" posting against the account "purchases"
£20,000 "debit" posting against the account "motor vehicles"
My posting table looks like this:
posting_id - int, primary key
account_id - in, foreign key
date - timestamp
sum - decimal
type - either "credit" or "debit"
I need to have a query where all postings will be listed, with each "credit" posting in one column and each "debit" in another. Each "credit" posting will have a NULL value in the "debit" column, and vice versa.
I have tried using an union query. As this seems like quite a common problem, does anyone have any suggestions?
Thanks!