File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -179,5 +179,39 @@ FROM Project p
179
179
LEFT JOIN Employee e
180
180
ON p .employee_id = e .employee_id
181
181
GROUP BY project_id
182
+ ```
183
+
184
+ [ 1633. Percentage of Users Attended a Contest] ( https://leetcode.com/problems/percentage-of-users-attended-a-contest )
185
+ ``` sql
186
+ -- % desc, contest_id asc, round 2
187
+ SELECT r .contest_id ,
188
+ ROUND(COUNT (DISTINCT r .user_id ) * 100 / (SELECT COUNT (DISTINCT user_id) FROM Users), 2 ) AS percentage
189
+ FROM Register r
190
+ GROUP BY r .contest_id
191
+ ORDER BY percentage DESC , r .contest_id ASC ;
192
+ ```
193
+
194
+ [ 1211 Queries Quality and Percentage] ( https://leetcode.com/problems/queries-quality-and-percentage )
195
+
196
+ ``` sql
197
+ -- quality - avg(rating/position), poor query % - %(rating < 3), round 2
198
+ SELECT query_name,
199
+ ROUND(AVG (rating/ position), 2 ) AS quality,
200
+ ROUND(SUM (IF(rating < 3 , 1 , 0 )) * 100 / COUNT (rating), 2 ) AS poor_query_percentage
201
+ FROM Queries
202
+ GROUP BY query_name
203
+
204
+ -- OR
205
+ SELECT query_name,
206
+ ROUND(AVG (rating/ position), 2 ) AS quality,
207
+ ROUND(SUM (
208
+ CASE WHEN rating < 3 THEN 1 ELSE 0 END
209
+ ) * 100 / COUNT (rating), 2 ) AS poor_query_percentage
210
+ FROM Queries
211
+ GROUP BY query_name
212
+ ```
213
+
214
+ [ 1193. Monthly Transactions I] ( https://leetcode.com/problems/monthly-transactions-i/ )
215
+ ``` sql
182
216
183
217
```
You can’t perform that action at this time.
0 commit comments