SELECT DISTINCT bumen AS bumen,
SUM(CASE type
WHEN 'a' THEN num END) AS a,
SUM(CASE type
WHEN 'c' THEN num END) AS c,
SUM(CASE type
WHEN 'b' THEN num END) AS b FROM ttt GROUP BY bumen;
image.png
image.png
SELECT DISTINCT bumen AS bumen,
SUM(CASE type
WHEN 'a' THEN num END) AS a,
SUM(CASE type
WHEN 'c' THEN num END) AS c,
SUM(CASE type
WHEN 'b' THEN num END) AS b FROM ttt GROUP BY bumen;
image.png
image.png
本文标题:列值分类转为列
本文链接:https://www.haomeiwen.com/subject/wifjlftx.html
网友评论