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 |
learzbu
Starting Member
27 Posts |
Posted - 2014-10-03 : 04:44:20
|
Is there anyway to get a sum of values from the below sample where Code=A? Code1 Code2 Code3 Val1 Val2 Val3A A B 1 5 8B A B 5 6 2Desired ResultVal = 12 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-10-03 : 09:08:53
|
select sum(case when code1 = 'A' then code1 end + case when code2 = 'A' then code2 end + case when code3 = 'A' then code3 end)from ... |
|
|
|
|
|