File tree 1 file changed +44
-0
lines changed
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,50 @@ WHERE visit_id NOT IN (SELECT DISTINCT visit_id FROM Transactions)
67
67
GROUP BY customer_id
68
68
```
69
69
70
+ 197 . Rising Temperature
71
+ ``` sql
72
+ SELECT w1 .id
73
+ FROM Weather w1, Weather w2
74
+ WHERE DATEDIFF(w1 .recordDate , w2 .recordDate ) = 1
75
+ AND w1 .temperature > w2 .temperature
76
+
77
+ -- OR
78
+ SELECT w1 .id
79
+ FROM Weather w1, Weather w2
80
+ WHERE w1 .temperature > w2 .temperature
81
+ AND SUBDATE(w1 .recordDate , 1 ) = w2 .recordDate
82
+ ```
70
83
84
+ 1661 . Average Time of Process per Machine
85
+ ``` sql
86
+ SELECT machine_id, ROUND(AVG (end - start), 3 ) AS processing_time
87
+ FROM
88
+ (SELECT machine_id, process_id,
89
+ MAX (CASE WHEN activity_type = ' start' THEN timestamp END) AS start,
90
+ MAX (CASE WHEN activity_type = ' end' THEN timestamp END) AS end
91
+ FROM Activity
92
+ GROUP BY machine_id, process_id) AS subq
93
+ GROUP BY machine_id
94
+ ```
71
95
96
+ 577 . Employee Bonus
97
+ ``` sql
98
+ SELECT name, bonus
99
+ FROM Employee e
100
+ LEFT JOIN Bonus b
101
+ ON e .empId = b .empId
102
+ WHERE bonus < 1000
103
+ OR bonus IS NULL
104
+ ```
72
105
106
+ 1280 . Students and Examinations
107
+ ``` sql
108
+ SELECT a .student_id , a .student_name , b .subject_name , COUNT (c .subject_name ) AS attended_exams
109
+ FROM Students a
110
+ JOIN Subjects b
111
+ LEFT JOIN Examinations c
112
+ ON a .student_id = c .student_id
113
+ AND b .subject_name = c .subject_name
114
+ GROUP BY 1 , 3
115
+ ORDER BY 1 , 3
116
+ ```
You can’t perform that action at this time.
0 commit comments