1633. Percentage of Users Attended a Contest

https://leetcode.com/problems/percentage-of-users-attended-a-contest

Description

Table: Users

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| user\_id     | int     |
| user\_name   | varchar |
+-------------+---------+
user\_id is the primary key for this table.
Each row of this table contains the name and the id of a user.

Table: Register

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| contest\_id  | int     |
| user\_id     | int     |
+-------------+---------+
(contest\_id, user\_id) is the primary key for this table.
Each row of this table contains the id of a user and the contest they registered into.

Write an SQL query 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.

The query result format is in the following example.

ac

Last updated

Was this helpful?