当前位置:网站首页>Leetcode: 1179. Reformat department table
Leetcode: 1179. Reformat department table
2022-07-22 19:09:00 【A master of East and West】
The original title is :https://leetcode-cn.com/problems/reformat-department-table/
# Write your MySQL query statement below
select id,
sum(case when month = 'Jan' then revenue end) as Jan_Revenue,
sum(case when month = 'Feb' then revenue end) as Feb_Revenue,
sum(case when month = 'Mar' then revenue end) as Mar_Revenue,
sum(case when month = 'Apr' then revenue end) as Apr_Revenue,
sum(case when month = 'May' then revenue end) as May_Revenue,
sum(case when month = 'Jun' then revenue end) as Jun_Revenue,
sum(case when month = 'Jul' then revenue end) as Jul_Revenue,
sum(case when month = 'Aug' then revenue end) as Aug_Revenue,
sum(case when month = 'Sep' then revenue end) as Sep_Revenue,
sum(case when month = 'Oct' then revenue end) as Oct_Revenue,
sum(case when month = 'Nov' then revenue end) as Nov_Revenue,
sum(case when month = 'Dec' then revenue end) as Dec_Revenue
from Department
group by id;
You have to use sum(), Otherwise take revenue The value of will be disordered , Most of them will change NULL, because group by The reason for grouping
边栏推荐
- 融云漫话:没有一个人躲得过“视频会议”
- Stm32+esp8266+mqtt protocol connects onenet IOT platform
- 2、 Idea build jfinal project + automatic code generation + database operation test (three ways)
- 逻辑回归中的损失函数
- nacos持久化连接mysql数据库sm4加密方案
- Image quality evaluation
- Problems encountered in using openfeign to realize remote call in Webflux
- Shell script debugging technology
- MIHA tour recruited a large number of new students, and the school enrollment was approved in advance on the last day!
- JUC-同步器
猜你喜欢
Flink learning notes (IV) Flink runtime architecture
MNIST handwritten numeral recognition case tensorflow 2.0 practice
【链表技巧汇总】141.环形链表(简单)
【YOLOv5实战4】基于YOLOv5的交通标志识别系统-模型测试与评估
[QT source code reuse] simulate the pop-up mode of qcompleter
MNIST手写数字识别案例TensorFlow 2.0 实践
Programmer interview golden code interview question 01.02. determine whether it is character rearrangement
程序员面试金典面试题 01.01. 判定字符是否唯一
Strncpy() copy string (limited by length)
How to add funding information when writing a paper with latex
随机推荐
numpy 求矩阵非零元素的均值
逻辑回归中的损失函数
卧式单面多轴钻孔组合机床动力滑台液压系统的设计
分库分表
JVM调优实战-从零开始 | 项目有关JVM调优总结
在各类数据库中随机查询n条数据
15 SQL optimizations commonly used by experts
1. A complete instance of movetothread, 2. QT expression evaluation
服务器运维环境安全体系(上篇)
[summary of linked list skills] 876. Intermediate node of linked list
【YOLOv5实战4】基于YOLOv5的交通标志识别系统-模型测试与评估
How to add funding information when writing a paper with latex
深度学习资料整理
Tcpdump 简单用法
Summary of all usage of join in SQL syntax (simple example)
1. Qimage filling transparent brush; 2.path.addtext how to add line breaks
WGet downloads all files in the directory
为什么重写equels方法一定要重写hashCode方法
Upgrade win10sp1 to the latest version; Qt5.9.6 static compilation (network is valid)
mysql5.7解压版配置步骤