Modify the sentence WHEREand use the operator CASEinstead to calculate the did-not-finish value. Then divide it into all riders. Something like that:
SELECT result.raceid, race.name, race.location, race.date,
COUNT(result.raceid) AS TOTAL,
SUM(CASE WHEN result.place = 0 THEN 1 ELSE 0 END) AS DNF,
SUM(CASE WHEN result.place = 0 THEN 1 ELSE 0 END) /
COUNT(result.raceid) AS PCT_DNF
FROM result
JOIN race ON result.raceid=race.id
GROUP BY result.raceid, race.name, race.location, race.date
ORDER BY SUM(CASE WHEN result.place = 0 THEN 1 ELSE 0 END) /
COUNT(result.raceid) DESC LIMIT 10
source
share