透视表导出--case when then else end 导出模板导出表格样式为透视表 导出模板 select col1, sum(case when col2 = 'key1' then 1 else 0 end) as 'key1', sum(case when col2 = 'key2' then 1 else 0 end) as 'key2', count(id) from `table_name` group by col1; 导出表格样式为透视表 col1key1key2count(id)name1value11value12value13name2value21value22value23