The simple solution

  • 0

    select t.Request_at 'Day', round(sum(case when t.Status like 'cancelled_%' then 1 else 0 end)/count(*),2) 'Cancellation Rate'
    from Trips t
    join Users uc
    on uc.Users_Id=t.Client_Id
    and uc.Role='client' and uc.Banned='No'
    join Users ud
    on ud.Users_Id=t.Driver_Id
    and ud.Role='driver'
    where t.Request_at between '2013-10-01' and '2013-10-03'
    group by t.Request_at;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.