一、code
1.1 题目描述
1.2 题解
# Write your MySQL query statement below
select a.request_at 'Day',
round(sum(if(a.status = 'completed',0,1))/count(*), 2) 'Cancellation Rate'
from
(
select
request_at, status
from
Trips
join Users u1 on client_id = u1.users_id and u1.banned = "No" # 司机与用户为一单
join Users u2 on driver_id = u2.users_id and u2.banned = "No"
where
request_at BETWEEN '2013-10-01' AND '2013-10-03'
) a
group by a.request_at # 分日期
;