I'm using PHP/MySQL to make a website that displays race results. I want to display a statistic of the 10 hardest races ie the races that most people DNF. I'm doing it like this:
select raceid,race.name,race.location,race.date,count(result.raceid) as dnfs
from result
inner join race on result.raceid=race.id
where result.place=0
group by result.raceid
order by dnfs desc limit 10
But that doesn't take in to account the number of people in the race. How would I modify the query to also return percentDNF (dnfs/totalracers) and order by that column? A place=0 means DNF.