leetcode 1179
记得用sum,否则多条数据会冲突
# Write your MySQL query statement below select id, sum(case when month='Jan' then revenue else null end) Jan_Revenue, sum(case when month='Feb' then revenue else null end) Feb_Revenue, sum(case when month='Mar' then revenue else null end) Mar_Revenue, sum(case when month='Apr' then revenue else null end) Apr_Revenue, sum(case when month='May' then revenue else null end) May_Revenue, sum(case when month='Jun' then revenue else null end) Jun_Revenue, sum(case when month='Jul' then revenue else null end) Jul_Revenue, sum(case when month='Aug' then revenue else null end) Aug_Revenue, sum(case when month='Sep' then revenue else null end) Sep_Revenue, sum(case when month='Oct' then revenue else null end) Oct_Revenue, sum(case when month='Nov' then revenue else null end) Nov_Revenue, sum(case when month='Dec' then revenue else null end) Dec_Revenue from Department group by id;

浙公网安备 33010602011771号