您可以一次完成所有源ID:
select source_id sum(case when plateCategoryId = 3 then 1 else 0 end) as TotalNewCount, sum(case when plateCategoryId = 4 then 1 else 0 end) as TotalOldCountfrom eventgroup by source_id;
如果要限制源ID,请使用
where(之前的
group by)。
注意:上面的代码在Vertica和MySQL中都可以使用,并且作为标准SQL可以在任何数据库中使用。



