Write a solution 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 result format is in the following example.
해당 값을 선택한 인원 수/전체 인원 수
를 계산해야 했던 문제SELECT contest_id,
ROUND(COUNT(DISTINCT user_id) / (SELECT COUNT(*) FROM Users) * 100 ,2) as percentage
FROM Register
GROUP BY 1
ORDER BY 2 desc, 1