楼主:
HelloJimmy (Angel Michael)
2015-03-02 23:09:40数据库名称:mySQL
数据库版本:5.6
内容/问题描述:
大家好,假设今天Table有两个字段,想将同一字段里的统计资料做横向展开,该如何做?例:
Name Product
select name,count(case when product=1 thenproduct else null end)"轮胎" ,count(case when product=2 then product else nullend)"茶杯" from table_name group by name;用sum 也可,跟一楼大大一样