来自:znxia, 时间:2009-5-15 8:53:04, ID:3958450 select Sum( Case when PatIndex('%纸%',lb)>0 then je else 0 end) as A, Sum( Case when PatIndex('%笔%',lb)>0 then je else 0 end) as BFrom table 语法错误
select f1, sum(je)from ( select t.*, (case when PatIndex('%纸%',lb)>0 then '纸' when PatIndex('%笔%',lb)>0 then '笔' else '其它' end) f1 From tablename t) agroup by f1