mysql的group_concat列转行函数

SELECT
   auditor,sum(count) total,
    GROUP_CONCAT(type,'=', count) AS type_count
FROM
    auditor_dm_ol
WHERE created = 20190402 
GROUP BY
    auditor
UNION 
SELECT a.auditor ,SUM(a.total),GROUP_CONCAT(a.type,'=',a.total) from (
SELECT 'all' auditor ,type,sum(count) total FROM
    auditor_dm_ol
WHERE created = 20190402 
GROUP BY type
    )a  ORDER BY  total desc

展示要求

 

数据结果

 

posted @ 2019-04-02 22:18  夜半钟声到客船  阅读(718)  评论(0编辑  收藏  举报