* Problem
Write a solution to find the percentage of the users registered in each contest rounded to two decimals.
Return the result table ordered by percentage in descending order. In case of a tie, order it by contest_id in ascending order.
Explanation:
All the users registered in contests 208, 209, and 210. The percentage is 100% and we sort them in the answer table by contest_id in ascending order.
Alice and Alex registered in contest 215 and the percentage is ((2/3) * 100) = 66.67%
Bob registered in contest 207 and the percentage is ((1/3) * 100) = 33.33%
* Final Solution (Success)
# Write your MySQL query statement below select contest_id , round( count(distinct user_id)*100/ (select count(user_id) from Users),2) as percentage from register group by contest_id order by percentage desc, contest_id |
'Study - Problems(IT) > LeetCode - SQL' 카테고리의 다른 글
1174.Immediate Food Delivery2 (4) | 2024.11.17 |
---|---|
1193.Monthly Transactions (0) | 2024.11.16 |
1211.Queries Quality and Percentage (0) | 2024.11.15 |
1075. Project Employees I (3) | 2024.11.10 |
1251.Average Selling Price (0) | 2024.11.08 |