LeetCode (Trips and Users ) - SQL

preview_player
Показать описание
Problem Link :
Рекомендации по теме
Комментарии
Автор

Another Approaches:

1). SELECT Request_at AS Day,  
round(sum(case when (status = "cancelled_by_driver" or status = "cancelled_by_client") then 1 else 0 end) / count(status), 2) as 'Cancellation Rate'
FROM Trips
where Request_at between '2013-10-01' and '2013-10-03'
and client_id not in (select users_id from users where banned = 'Yes')
and driver_id not in (select users_id from users where banned = 'Yes')
group by Request_at;

2). SELECT Request_at AS Day,
round(sum(case when (status != "completed") then 1 else 0 end) / count(status), 2) as 'Cancellation Rate'
FROM Trips
where Request_at between '2013-10-01' and '2013-10-03'
and client_id not in (select users_id from users where banned = 'Yes')
and driver_id not in (select users_id from users where banned = 'Yes')
group by Request_at;

datasilicon