[문제]
[MySQL]
WITH Users_cnt AS (SELECT *
, COUNT(*) OVER () AS user_cnt
FROM Users
)
SELECT r.contest_id
, ROUND(COUNT(DISTINCT r.user_id) / u.user_cnt *100 , 2) AS percentage
FROM Register AS r
LEFT JOIN Users_cnt AS u ON r.user_id = u.user_id
GROUP BY r.contest_id
ORDER BY percentage DESC, contest_id ASC
'SQL > LeetCode' 카테고리의 다른 글
| [LeetCode] 1667. Fix Names in a Table (0) | 2025.02.21 |
|---|---|
| [LeetCode] 1661. Average Time of Process per Machine (0) | 2025.02.20 |
| [LeetCode] 1587. Bank Account Summary II (0) | 2025.02.20 |
| [LeetCode] 1581. Customer Who Visited but Did Not Make Any Transactions (0) | 2025.02.20 |
| [LeetCode] 1527. Patients With a Condition (0) | 2025.02.20 |
