Problem
Table: Users
|
|
id is the primary key for this table. name is the name of the user.
Table: Rides
|
|
id is the primary key for this table. user_id is the id of the user who traveled the distance “distance”.
Write an SQL query to report the distance traveled by each user.
Return the result table ordered by travelled_distance in descending order, if two or more users traveled the same distance, order them by their name in ascending order.
Solution
Method 1 - Right Join
Code
|
|