文巾解题 1179. 重新格式化部门表
Posted 刘文巾
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文巾解题 1179. 重新格式化部门表相关的知识,希望对你有一定的参考价值。
1 题目描述
2 解题思路
SELECT id,
sum(if(month='Jan',revenue,null)) as Jan_Revenue,
sum(if(month='Feb',revenue,null)) as Feb_Revenue,
sum(if(month='Mar',revenue,null)) as Mar_Revenue,
sum(if(month='Apr',revenue,null)) as Apr_Revenue,
sum(if(month='May',revenue,null)) as May_Revenue,
sum(if(month='Jun',revenue,null)) as Jun_Revenue,
sum(if(month='Jul',revenue,null)) as Jul_Revenue,
sum(if(month='Aug',revenue,null)) as Aug_Revenue,
sum(if(month='Sep',revenue,null)) as Sep_Revenue,
sum(if(month='Oct',revenue,null)) as Oct_Revenue,
sum(if(month='Nov',revenue,null)) as Nov_Revenue,
sum(if(month='Dec',revenue,null)) as Dec_Revenue
FROM department
GROUP BY id
以上是关于文巾解题 1179. 重新格式化部门表的主要内容,如果未能解决你的问题,请参考以下文章
⭐️ LeetCode解题系列 ⭐️ 1179. 重新格式化部门表(Oracle Pivot 行转列函数)