问题描述

262. Trips and Users-LMLPHP

解决方案

-- case when 的效率比if的效率高
-- select Trips.Request_at as 'Day',
-- round(sum(case Trips.Status when 'completed' then 0 else 1 end)/sum(1),2) as 'Cancellation Rate' -- SELECT Trips.Request_at Day,
-- round(sum(if(status != 'completed', 1, 0)) / sum(1), 2) 'Cancellation Rate' from Trips
join Users
on Trips.Client_Id =Users.Users_Id
where Users.Banned='No' and Trips.Request_at between '2013-10-01' and '2013-10-03'
group by Trips.Request_at
05-26 08:22