行转列列传行更具体例子
1、查看数据
Sql代码
- SELECT * FROM tabName ;
2、列转行统计数据
Sql代码
- SELECT DATE ,
- MAX(CASE NAME WHEN '小说' THEN Scount ELSE 0 END ) 小说,
- MAX(CASE NAME WHEN '微信' THEN Scount ELSE 0 END ) 微信
- FROM TabName
- GROUP BY DATE
3、行转列
Sql代码
- SELECT DATE,GROUP_CONCAT(NAME) FROM tabname GROUP BY DATE
4、行转列统计数据
Sql代码
- SELECT DATE, GROUP_CONCAT(NAME,'总量:',Scount) AS b_str FROM tabName GROUP BY DATE
Sql代码
- SELECT DATE,NAME, GROUP_CONCAT(NAME,'总量:',Scount) AS b_str FROM TabName GROUP BY DATE ,NAME