Expressions and a defensible denominator
Part 1 of 2
Use a defensible average
AVG skips NULL values; it does not treat a missing finish time as zero. An average needs both a stated population and a stated unit.
ROUND(AVG(finish_minutes), 2) rounds the final average. Averaging individually rounded values is a different computation.
Worked example
SELECT ROUND(AVG(finish_minutes), 2) AS avg_minutes FROM results WHERE race_type = 'Marathon';
Pause and explain. Why does replacing missing finish times with zero change the business answer? What population and units must accompany this average?
Part 2 of 2
Build a reliable leaderboard
SQLite sorts NULLs first in ascending order. Filter unknown times out before asking for the fastest finishers.
ORDER BY finish_minutes ASC, id ASC makes time ties deterministic. LIMIT selects a ranked subset; it does not create one aggregate row.
Worked example
SELECT first_name, last_name, finish_minutes FROM results WHERE race_type = 'Marathon' AND finish_minutes IS NOT NULL ORDER BY finish_minutes, id LIMIT 3;
Pause and explain. What goes wrong without IS NOT NULL? Do five result rows necessarily mean five different people?