문제
Loading...
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
![](https://leetcode.com/static/images/LeetCode_Sharing.png)
정답
SELECT Users.name,
IF (ISNULL(sum(Rides.distance)), 0, sum(Rides.distance)) as travelled_distance
FROM Users
LEFT JOIN Rides ON Users.id = Rides.user_id
GROUP BY Users.id
ORDER BY travelled_distance DESC, name