今天和大家聊的问题叫做 行程和用户,我们先来看题面:https://leetcode-cn.com/problems/single-number-iii/
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".
写一段 SQL 语句查出 "2013-10-01" 至 "2013-10-03" 期间非禁止用户(乘客和司机都必须未被禁止)的取消率。非禁止用户即 Banned 为 No 的用户,禁止用户即 Banned 为 Yes 的用户。
解题
# 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;
好了,今天的文章就到这里,如果觉得有所收获,请顺手点个在看或者转发吧,你们的支持是我最大的动力 。