This is the simplest one among the hard questions...


  • 0
    C

    This could be really simple as:

    select Request_at as Day, 
    round(count(If(Status like 'cancelled_by%' and Banned = 'No', Status, NULL))/count(If(Banned = 'No', Status, NULL)),2) as 'Cancellation Rate'
    from Trips t join Users u
    on t.Client_Id = u.Users_Id
    where Request_at between '2013-10-01' and '2013-10-03'
    group by Request_at
    
    

  • 0
    D

    But what about driver is Banned? You only join on client_id = user_id; what about driver_id = user_id?

    @catseye1007 said in This is the simplest one among the hard questions...:

    select Request_at as Day,
    round(count(If(Status like 'cancelled_by%' and Banned = 'No', Status, NULL))/count(If(Banned = 'No', Status, NULL)),2) as 'Cancellation Rate'
    from Trips t join Users u
    on t.Client_Id = u.Users_Id
    where Request_at between '2013-10-01' and '2013-10-03'
    group by Request_at


Log in to reply
 

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