Leetcode Note: MySQL - Top Travellers
Top Travellers - LeetCode
https://leetcode.com/problems/top-travellers/
- MySQL で取り組んだメモ
回答
405ms MySQL Solution - Top Travellers - LeetCode
https://leetcode.com/problems/top-travellers/solutions/580316/405ms-mysql-solution/
select u.name, ifnull(sum(r.distance), 0) as travelled_distance
from users u
left join rides r
on u.id = r.user_id
group by r.user_id
order by travelled_distance desc, u.name asc