LeetCode solutions

1773. Percentage of Users Attended a Contest

My accepted SQL solution to LeetCode problem 1773, Percentage of Users Attended a Contest, running in 857ms.

  • Difficulty: Easy
  • SQL
  • Runtime 857ms
  • Memory 0.0B

Read the problem on LeetCode View on GitHub

SQL

Accepted on LeetCode — runtime 857ms, memory 0.0B, accepted 2025-12-31.

sql
SELECT r.contest_id, 
       ROUND(COUNT(r.user_id) * 100.0 / (SELECT COUNT(*) FROM Users), 2) AS percentage
FROM Register r
GROUP BY r.contest_id
ORDER BY percentage DESC, r.contest_id ASC

Source