Skip to content

Commit 73eb36d

Browse files
committed
Upload 150
1 parent d9534ce commit 73eb36d

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ The problems and both submitted and site solutions are documented in individual
182182
| 147 | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/description/) | [Solution](solutions/147_customer_placing_the_largest_number_of_orders.md) | LeetCode | Easy | `ORDER BY` w/ Aggregate Function |
183183
| 148 | [Swap Salary](https://leetcode.com/problems/swap-salary/description/) | [Solution](solutions/148_swap_salary.md) | LeetCode | Easy | |
184184
| 149 | [Sales Person](https://leetcode.com/problems/sales-person/description/) | [Solution](solutions/149_sales_person.md) | LeetCode | Easy | |
185+
| 150 | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table/description/) | [Solution](solutions/150_reformat_department_table.md) | LeetCode | Easy | |
185186
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
186187

187188
## Author(s)

eevveerryyddaayy.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"metadata": {
1919
"kernelspec": {
20-
"display_name": "venv",
20+
"display_name": "sql-everyday_venv",
2121
"language": "python",
2222
"name": "python3"
2323
},
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# SQL Everyday \#150
2+
3+
## Reformat Department Table
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Easy
7+
8+
## Problem
9+
10+
Reformat the table such that there is a department id column and a revenue column *for each month*.
11+
12+
Return the result table in *any order*. [[Full Description](https://leetcode.com/problems/reformat-department-table/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
SELECT
19+
id,
20+
MAX(CASE WHEN month = 'Jan' THEN revenue END) AS Jan_Revenue,
21+
MAX(CASE WHEN month = 'Feb' THEN revenue END) AS Feb_Revenue,
22+
MAX(CASE WHEN month = 'Mar' THEN revenue END) AS Mar_Revenue,
23+
MAX(CASE WHEN month = 'Apr' THEN revenue END) AS Apr_Revenue,
24+
MAX(CASE WHEN month = 'May' THEN revenue END) AS May_Revenue,
25+
MAX(CASE WHEN month = 'Jun' THEN revenue END) AS Jun_Revenue,
26+
MAX(CASE WHEN month = 'Jul' THEN revenue END) AS Jul_Revenue,
27+
MAX(CASE WHEN month = 'Aug' THEN revenue END) AS Aug_Revenue,
28+
MAX(CASE WHEN month = 'Sep' THEN revenue END) AS Sep_Revenue,
29+
MAX(CASE WHEN month = 'Oct' THEN revenue END) AS Oct_Revenue,
30+
MAX(CASE WHEN month = 'Nov' THEN revenue END) AS Nov_Revenue,
31+
MAX(CASE WHEN month = 'Dec' THEN revenue END) AS Dec_Revenue
32+
FROM Department
33+
GROUP BY id
34+
ORDER BY id
35+
;
36+
```
37+
38+
## Site Solution
39+
40+
```sql
41+
-- LeetCode Solution
42+
-- TBD
43+
```
44+
45+
## Notes
46+
47+
TBD
48+
49+
## NB
50+
51+
TBD
52+
53+
Go to [Index](../?tab=readme-ov-file#index)\
54+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)