LeetCode 262 - Trips and Users - Hard SQL Interview

preview_player
Показать описание
In this video we solve Leetcode 262- Trips and Users using SQL. These types of SQL interview questions/problems are often used by FAANG (Facebook/Meta, Amazon, Apple, Netflix and Google) and similar tech companies. This tutorial/walkthrough will serve as a step-by-step solution to the problem.

To solve this, I demonstrate a step-by-step walkthrough of creating a subset of data using a Common Table Expression (CTE), specifically by joining the same table twice to pull clients and then drivers, and then perform my computations to reach the end result.

Please give the video a THUMBS UP if you found it helpful. Your support to the channel is appreciated.

Here is the code I wrote:

with cte_daily_cancellations as (
Select

, count(*) ct_total_requests

from
Trips t
inner join Users u
inner join Users d
)

select
request_at as Day
, round(ct_cancelled / ct_total_requests, 2) as 'Cancellation Rate'
from cte_daily_cancellations

#sql #sql101 #leetcode
Рекомендации по теме