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 |
sadderson
Starting Member
13 Posts |
Posted - 2013-08-15 : 16:59:17
|
DataCategory 1 Category 2 Name Option 31 0 Dave no2 5 Fred no3 1 Don yes4 1 Ted no 1 1 Dave yes2 2 Fred yesWhat I need is to total category 1 and category 2 for Name but only add Category 2 if Option 3 is yes.. |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-08-15 : 17:12:06
|
perhaps this?select sum(category1) ,sum( case when option3 = 'yes' then category2 else 0 end) as category2from yourTablegroup by name Be One with the OptimizerTG |
|
|
sadderson
Starting Member
13 Posts |
Posted - 2013-08-15 : 18:04:54
|
Fantastic... did exactly what I wanted...Scott |
|
|
|
|
|