I have made a website for a ‘walking challenge’, which has a table that logs miles walked.
The target is 2105 miles (Newcastle, UK to Istanbul).
On the home page i have a leaderboard which currently shows the 5 teams who have racked up the most miles.
I am using the following query to achive this:
SELECT
SUM(log.distance) AS l,
log.*,
team.*
FROM
team
RIGHT JOIN
log ON team.teamname = log.teamname
GROUP BY
log.teamname
ORDER BY
l DESC
However i want this leaderboard to show the 5 teams that finished first rather than who have walked the furthest. ie, the teams who reached 2105 miles first.
The current website can be viewed here
Add a nullable
completedDatefield to the table and populate it whenever someone completes the race. Order by the completed date.There’d be no way to order by who finished first otherwise.