这是我的查询
select
(sum(case when offer1_delivered is not null then 1 else null end) ) as PenetrationRate1
,(sum(case when offer2_delivered is not null then 1 else null end)) as PenetrationRate2
,count(TargetMkgListID) as TargetMkgListID from tablename
输出
PenetrationRate1 PenetrationRate2 TargetMkgListID
1 2 3
我需要在此查询中包含 customername 列
select customername,
(sum(case when offer1_delivered is not null then 1 else null end) ) as PenetrationRate1
,(sum(case when offer2_delivered is not null then 1 else null end)) as PenetrationRate2
,count(TargetMkgListID) as TargetMkgListID from tablename
group by customername
如果我在查询中包含客户名称,则 groupby 无法正常工作。