LeetCode 1407 Interview SQL Question with Detailed Explanation | Practice SQL

preview_player
Показать описание
Previous Video: LeetCode 1378 Student Id Replace with Unique Identifier

In this video I solve and explain a leetcode SQL question using MySQL query. This question has been asked in Apple, Facebook, Amazon, Google, Adobe, Microsoft, Adobe interviews or what we popularly call FAANG interviews.
I explain the related concept as well. This question is about top travellers and also includes points to keep in mind to develop SQL queries.

LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.

If you found this helpful, Like and Subscribe to the channel for more content.

#LeetCodeSQL #FAANG #SQLinterviewQuestions
Рекомендации по теме
Комментарии
Автор

Sir, Thanks a lot for This Amazing Video 😊
Problem - 26 Solved ✅ in Practice SQL - LeetCode 👩🏻‍💻

PrithaMajumder
Автор

Instead of partition after left join we can group the names with sum( distance) then use isnull or if function for r.distance column we can replace the null value with 0

gagansingh
Автор

select distinct name, by r.user_id order by r.user_id ), 0)as travelled_distance
from users u
left join rides r on u.id=r.user_id
order by travelled_distance desc, u.name asc
One can use coalesce function to skip case when but it's not begineeer friendly bcoz above will make your logic

ManasNandMohan
Автор

with cte as
(
select user_id,
sum(distance)as travelled_distance
from Rides
group by user_id
)
select u.name,
ifnull(c.travelled_distance, 0) as travelled_distance
from Users u
left join cte c on u.id=c.user_id
order by travelled_distance desc, name asc;



Not Understood Over partition

sukumar-mt