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

展示要求

 

数据结果

原文地址:https://www.cnblogs.com/hejunhong/p/10645828.html