Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Calculated Columns

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2015-03-05 : 18:34:20
I have these three columns ID, Amount, and Type. What I want are 5 columns: ID, Amount, Debit, Credit, Type. Type tells me if the transaction is Debit or Credit, but I need to bucket the Amount into either Debit or Credit, based on Type = "Credit" or "Debit". Any help would be appreciated.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-03-05 : 21:06:59
in your create table statement:
...
Debit as (case when Type='Debit' then Amount END),
Credit as (case when type='Credit' then Amount end),
...
Go to Top of Page
   

- Advertisement -