解题思路:
根据题意要求出每个赛事的注册率,首先就要确定有多少参赛用户
1.求出用户数量
select count(*) as total from users
2.按照contest_id进行分组,求出每个赛事有多少用户参赛
select contest_id,count(user_id)
from Register
group by contest_id
3.最后将上一步求出的count数量除以第一步得出的count数量得出注册率,并按照题中要求对结果进行排序
select contest_id,Round((count(user_id)/(select count(*) as total from users))*100,2) as percentage
from Register
group by contest_id
order by percentage desc,contest_id