File tree 7 files changed +454
-39
lines changed
1179.Reformat Department Table
1180.Count Substrings with Only One Distinct Letter
7 files changed +454
-39
lines changed Original file line number Diff line number Diff line change @@ -57,26 +57,88 @@ Department 表:
57
57
58
58
<!-- tabs:start -->
59
59
60
- ### ** Python3**
61
-
62
- <!-- 这里可写当前语言的特殊实现逻辑 -->
63
-
64
- ``` python
65
-
66
- ```
67
-
68
- ### ** Java**
69
-
70
- <!-- 这里可写当前语言的特殊实现逻辑 -->
71
-
72
- ``` java
73
-
74
- ```
75
-
76
- ### ** ...**
77
-
78
- ```
79
-
60
+ ### ** SQL**
61
+
62
+ ``` sql
63
+ # Write your MySQL query statement below
64
+ select
65
+ id,
66
+ sum (
67
+ case
68
+ month
69
+ when ' Jan' then revenue
70
+ end
71
+ ) as Jan_Revenue,
72
+ sum (
73
+ case
74
+ month
75
+ when ' Feb' then revenue
76
+ end
77
+ ) as Feb_Revenue,
78
+ sum (
79
+ case
80
+ month
81
+ when ' Mar' then revenue
82
+ end
83
+ ) as Mar_Revenue,
84
+ sum (
85
+ case
86
+ month
87
+ when ' Apr' then revenue
88
+ end
89
+ ) as Apr_Revenue,
90
+ sum (
91
+ case
92
+ month
93
+ when ' May' then revenue
94
+ end
95
+ ) as May_Revenue,
96
+ sum (
97
+ case
98
+ month
99
+ when ' Jun' then revenue
100
+ end
101
+ ) as Jun_Revenue,
102
+ sum (
103
+ case
104
+ month
105
+ when ' Jul' then revenue
106
+ end
107
+ ) as Jul_Revenue,
108
+ sum (
109
+ case
110
+ month
111
+ when ' Aug' then revenue
112
+ end
113
+ ) as Aug_Revenue,
114
+ sum (
115
+ case
116
+ month
117
+ when ' Sep' then revenue
118
+ end
119
+ ) as Sep_Revenue,
120
+ sum (
121
+ case
122
+ month
123
+ when ' Oct' then revenue
124
+ end
125
+ ) as Oct_Revenue,
126
+ sum (
127
+ case
128
+ month
129
+ when ' Nov' then revenue
130
+ end
131
+ ) as Nov_Revenue,
132
+ sum (
133
+ case
134
+ month
135
+ when ' Dec' then revenue
136
+ end
137
+ ) as Dec_Revenue
138
+ from
139
+ Department
140
+ group by
141
+ id
80
142
```
81
143
82
144
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -58,22 +58,88 @@ Note that the result table has 13 columns (1 for the department id + 12 for the
58
58
59
59
<!-- tabs:start -->
60
60
61
- ### ** Python3**
62
-
63
- ``` python
64
-
65
- ```
66
-
67
- ### ** Java**
68
-
69
- ``` java
70
-
71
- ```
72
-
73
- ### ** ...**
74
-
75
- ```
76
-
61
+ ### ** SQL**
62
+
63
+ ``` sql
64
+ # Write your MySQL query statement below
65
+ select
66
+ id,
67
+ sum (
68
+ case
69
+ month
70
+ when ' Jan' then revenue
71
+ end
72
+ ) as Jan_Revenue,
73
+ sum (
74
+ case
75
+ month
76
+ when ' Feb' then revenue
77
+ end
78
+ ) as Feb_Revenue,
79
+ sum (
80
+ case
81
+ month
82
+ when ' Mar' then revenue
83
+ end
84
+ ) as Mar_Revenue,
85
+ sum (
86
+ case
87
+ month
88
+ when ' Apr' then revenue
89
+ end
90
+ ) as Apr_Revenue,
91
+ sum (
92
+ case
93
+ month
94
+ when ' May' then revenue
95
+ end
96
+ ) as May_Revenue,
97
+ sum (
98
+ case
99
+ month
100
+ when ' Jun' then revenue
101
+ end
102
+ ) as Jun_Revenue,
103
+ sum (
104
+ case
105
+ month
106
+ when ' Jul' then revenue
107
+ end
108
+ ) as Jul_Revenue,
109
+ sum (
110
+ case
111
+ month
112
+ when ' Aug' then revenue
113
+ end
114
+ ) as Aug_Revenue,
115
+ sum (
116
+ case
117
+ month
118
+ when ' Sep' then revenue
119
+ end
120
+ ) as Sep_Revenue,
121
+ sum (
122
+ case
123
+ month
124
+ when ' Oct' then revenue
125
+ end
126
+ ) as Oct_Revenue,
127
+ sum (
128
+ case
129
+ month
130
+ when ' Nov' then revenue
131
+ end
132
+ ) as Nov_Revenue,
133
+ sum (
134
+ case
135
+ month
136
+ when ' Dec' then revenue
137
+ end
138
+ ) as Dec_Revenue
139
+ from
140
+ Department
141
+ group by
142
+ id
77
143
```
78
144
79
145
<!-- tabs:end -->
Original file line number Diff line number Diff line change
1
+ # Write your MySQL query statement below
2
+ select
3
+ id,
4
+ sum (
5
+ case
6
+ month
7
+ when ' Jan' then revenue
8
+ end
9
+ ) as Jan_Revenue,
10
+ sum (
11
+ case
12
+ month
13
+ when ' Feb' then revenue
14
+ end
15
+ ) as Feb_Revenue,
16
+ sum (
17
+ case
18
+ month
19
+ when ' Mar' then revenue
20
+ end
21
+ ) as Mar_Revenue,
22
+ sum (
23
+ case
24
+ month
25
+ when ' Apr' then revenue
26
+ end
27
+ ) as Apr_Revenue,
28
+ sum (
29
+ case
30
+ month
31
+ when ' May' then revenue
32
+ end
33
+ ) as May_Revenue,
34
+ sum (
35
+ case
36
+ month
37
+ when ' Jun' then revenue
38
+ end
39
+ ) as Jun_Revenue,
40
+ sum (
41
+ case
42
+ month
43
+ when ' Jul' then revenue
44
+ end
45
+ ) as Jul_Revenue,
46
+ sum (
47
+ case
48
+ month
49
+ when ' Aug' then revenue
50
+ end
51
+ ) as Aug_Revenue,
52
+ sum (
53
+ case
54
+ month
55
+ when ' Sep' then revenue
56
+ end
57
+ ) as Sep_Revenue,
58
+ sum (
59
+ case
60
+ month
61
+ when ' Oct' then revenue
62
+ end
63
+ ) as Oct_Revenue,
64
+ sum (
65
+ case
66
+ month
67
+ when ' Nov' then revenue
68
+ end
69
+ ) as Nov_Revenue,
70
+ sum (
71
+ case
72
+ month
73
+ when ' Dec' then revenue
74
+ end
75
+ ) as Dec_Revenue
76
+ from
77
+ Department
78
+ group by
79
+ id
You can’t perform that action at this time.
0 commit comments