SQLSQL
#27

Calculate Contest Participation Percentage in SQL

Easy
Interview Question #27

Given `users` (user_id) and `register` (contest_id, user_id), find the percentage of total users registered in each contest, rounded to 2 decimal places. Sort by percentage descending, then contest_id ascending.

Input Table: users & register
3 rows preview
user_idcontest_id
6215
6209
7215
Expected Output Structure2 rows
contest_idpercentage
21566.67
20933.33
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us