File tree 10 files changed +94
-9
lines changed
0600-0699/0627.Swap Salary
1661.Average Time of Process per Machine
1677.Product's Worth Over Invoices
10 files changed +94
-9
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ node_modules/
14
14
/solution /bash_problem_readme_template.md
15
15
/solution /bash_problem_readme_template_en.md
16
16
/solution /0100-0199 /0177.Nth Highest Salary /Solution.sql
17
+ /solution /0600-0699 /0627.Swap Salary /Solution.sql
17
18
/solution /1000-1099 /1076.Project Employees II /Solution.sql
18
19
/solution /1000-1099 /1082.Sales Analysis I /Solution.sql
19
20
/solution /1100-1199 /1173.Immediate Food Delivery I /Solution.sql
Original file line number Diff line number Diff line change @@ -78,4 +78,10 @@ SET sex = CASE sex
78
78
END;
79
79
```
80
80
81
+ ``` sql
82
+ # Write your MySQL query statement below
83
+ UPDATE Salary
84
+ SET sex = if(sex = ' f' , ' m' , ' f' );
85
+ ```
86
+
81
87
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -70,4 +70,10 @@ SET sex = CASE sex
70
70
END;
71
71
```
72
72
73
+ ``` sql
74
+ # Write your MySQL query statement below
75
+ UPDATE Salary
76
+ SET sex = if(sex = ' f' , ' m' , ' f' );
77
+ ```
78
+
73
79
<!-- tabs:end -->
Original file line number Diff line number Diff line change 1
- UPDATE salary
2
- SET sex = CASE sex
3
- WHEN ' m' THEN ' f'
4
- ELSE ' m'
5
- END;
1
+ # Write your MySQL query statement below
2
+ UPDATE Salary
3
+ SET sex = if(sex = ' f' , ' m' , ' f' );
Original file line number Diff line number Diff line change @@ -84,7 +84,20 @@ Activity table:
84
84
### ** SQL**
85
85
86
86
``` sql
87
-
87
+ # Write your MySQL query statement below
88
+ SELECT
89
+ machine_id,
90
+ round(
91
+ avg (
92
+ CASE
93
+ WHEN activity_type = ' start' THEN - timestamp
94
+ ELSE timestamp
95
+ END
96
+ ) * 2 ,
97
+ 3
98
+ ) AS processing_time
99
+ FROM Activity
100
+ GROUP BY machine_id;
88
101
```
89
102
90
103
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -80,7 +80,20 @@ Machine 2's average time is ((4.512 - 4.100) + (5.000 - 2.500)) / 2 = 1.456
80
80
### ** SQL**
81
81
82
82
``` sql
83
-
83
+ # Write your MySQL query statement below
84
+ SELECT
85
+ machine_id,
86
+ round(
87
+ avg (
88
+ CASE
89
+ WHEN activity_type = ' start' THEN - timestamp
90
+ ELSE timestamp
91
+ END
92
+ ) * 2 ,
93
+ 3
94
+ ) AS processing_time
95
+ FROM Activity
96
+ GROUP BY machine_id;
84
97
```
85
98
86
99
<!-- tabs:end -->
Original file line number Diff line number Diff line change
1
+ # Write your MySQL query statement below
2
+ SELECT
3
+ machine_id,
4
+ round(
5
+ avg (
6
+ CASE
7
+ WHEN activity_type = ' start' THEN - timestamp
8
+ ELSE timestamp
9
+ END
10
+ ) * 2 ,
11
+ 3
12
+ ) AS processing_time
13
+ FROM Activity
14
+ GROUP BY machine_id;
Original file line number Diff line number Diff line change @@ -93,7 +93,18 @@ Result 表:
93
93
### ** SQL**
94
94
95
95
``` sql
96
-
96
+ # Write your MySQL query statement below
97
+ SELECT
98
+ name,
99
+ ifnull(sum (rest), 0 ) AS rest,
100
+ ifnull(sum (paid), 0 ) AS paid,
101
+ ifnull(sum (canceled), 0 ) AS canceled,
102
+ ifnull(sum (refunded), 0 ) AS refunded
103
+ FROM
104
+ Product
105
+ LEFT JOIN Invoice USING (product_id)
106
+ GROUP BY product_id
107
+ ORDER BY name;
97
108
```
98
109
99
110
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -96,7 +96,18 @@ Invoice table:
96
96
### ** SQL**
97
97
98
98
``` sql
99
-
99
+ # Write your MySQL query statement below
100
+ SELECT
101
+ name,
102
+ ifnull(sum (rest), 0 ) AS rest,
103
+ ifnull(sum (paid), 0 ) AS paid,
104
+ ifnull(sum (canceled), 0 ) AS canceled,
105
+ ifnull(sum (refunded), 0 ) AS refunded
106
+ FROM
107
+ Product
108
+ LEFT JOIN Invoice USING (product_id)
109
+ GROUP BY product_id
110
+ ORDER BY name;
100
111
```
101
112
102
113
<!-- tabs:end -->
Original file line number Diff line number Diff line change
1
+ # Write your MySQL query statement below
2
+ SELECT
3
+ name,
4
+ ifnull(sum (rest), 0 ) AS rest,
5
+ ifnull(sum (paid), 0 ) AS paid,
6
+ ifnull(sum (canceled), 0 ) AS canceled,
7
+ ifnull(sum (refunded), 0 ) AS refunded
8
+ FROM
9
+ Product
10
+ LEFT JOIN Invoice USING (product_id)
11
+ GROUP BY product_id
12
+ ORDER BY name;
You can’t perform that action at this time.
0 commit comments