select r.contest_id,
round(count(r.user_id)/(select count(*) from Users)*100,2) percentage
from Users u
right join Register r
on u.user_id = r.user_id
group by contest_id
order by percentage desc,contest_id asc;
注意其中镶嵌的这个select语句,用来统计总的用户数
select r.contest_id,
round(count(r.user_id)/(select count(*) from Users)*100,2) percentage
from Users u
right join Register r
on u.user_id = r.user_id
group by contest_id
order by percentage desc,contest_id asc;
注意其中镶嵌的这个select语句,用来统计总的用户数