A栏位str1~str10 B栏位AA~ZZ C栏位为不同数值 1、A栏位为(str1,str2,str3) 只抓取B栏位为'AA' 的栏位C加总和 条件2、A栏位为(str4,str5,str6) 只抓取B栏位为'BB' 的值栏位C加总和 (((要如何下筛选语法呢? :SQL SERVER
sum(case when A in ('str1','str2','str3') and b = 'AA' then c else 0 end) 'c汇总1',
sum(case when A in ('str4','str5','str6') and b = 'BB' then c else 0 end) 'c汇总2'
select
sum(case when name in ('str1','str2','str3') and type = 'AA' then value else 0 end )'c汇总1',
sum(case when name in ('str4','str5','str6') and type = 'BB' then value else 0 end ) 'c汇总2'
from NB_Cow