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.
| Author |
Topic |
|
sameerv
Starting Member
29 Posts |
Posted - 2003-11-13 : 10:06:44
|
| I have a table with the following structure:ID numericTransactionType char(1){Credit/Debit}Amount numeric The rows in the table are: ID TransactionType Amount1 C 1002 D 503 D 2004 C 75I need a single Query to create a view whose output will be:ID Credit Debit 1 100 Null 2 Null 50 3 Null 200 4 75 Null |
|
|
nic
Posting Yak Master
209 Posts |
Posted - 2003-11-13 : 11:13:44
|
try thisSELECT ID ,(CASE WHEN TransactionType = 'C' THEN Amount ELSE Null END) AS Credit ,(CASE WHEN TransactionType = 'D' THEN Amount ELSE Null END) AS DebitFROM table Nic |
 |
|
|
|
|
|