select * from dbo.Sheet1$;
select 系列,SUM(访客数)as 访客数 from dbo.Sheet1$
where 来源名称 like '%精油%'
or 来源名称 like '%小o%'
group by 系列;
原数据是这样子的
想实现的效果是这样子的:精油35,护发素访客14,小o访客44,所以最后结果要是93.
简单来说就是对这些词进行重复统计,而where+or好像不能重复统计
希望解答,谢谢~
试试这样
select
SUM(case when 来源名称 like '%精油%' then 访客数 else 0 end )as 精油访客数,
SUM(case when 来源名称 like '%小o%' then 访客数 else 0 end )as 小o访客数,
SUM(case when 来源名称 like '%护发素%' then 访客数 else 0 end )as 护发素访客数
from dbo.Sheet1$