LeetCode刷题实战262:行程和用户
Write a SQL query to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between "2013-10-01" and "2013-10-03".
解题
# Write your MySQL query statement below
select t.Request_at Day,ROUND(sum((case when t.Status like 'cancelled%' then 1 else 0 end))/count(*),2) as'Cancellation Rate'
from Trips t
inner join Users u on u.Users_Id =t.Client_Id and u.Banned = 'No'
where t.Request_at between '2013-10-01'and'2013-10-03' group by t.Request_at;
赞 (0)