group by+ sum case 同一字段 不同值的分组统计_sql group by 罗列同一列不同值-CSDN博客

网站介绍:文章浏览阅读410次。需求描述:对文章按国家分组,统计正面,负面,中立态度分别统计select(SELECT cn_name FROM country_info where auto_id= t.country_id) name,t.country_id,sum(case when t.support_level=1 then 1 else 0 end) zheng,sum(case when t.support_level=2 then 1 else 0 end) fu,sum(case when t.su..._sql group by 罗列同一列不同值