1. 程式人生 > >mysql的group_concat列轉行函數

mysql的group_concat列轉行函數

weight style ont pan total from order span audit

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

mysql的group_concat列轉行函數