2025-08-10 08:14:30 +0000 UTC
Percentage of Users Attended a Contest
Categories:
Links
Code
WITH total_users AS (
SELECT
COUNT(DISTINCT user_id) AS total_count
FROM
Users
)
SELECT
Register.contest_id,
ROUND(
COUNT(DISTINCT Register.user_id) * 100.0 / total_users.total_count,
2
) AS percentage
FROM
Register
CROSS JOIN
total_users
GROUP BY
Register.contest_id,
total_users.total_count
ORDER BY
percentage DESC,
Register.contest_id;