My solution accepted by 115ms


  • 1
    T

    select
    list itemrequest_at as Day,
    round(sum(case when t.status like 'cancelled_by_%' then 1 else 0 end)/count(*),2) as 'Cancellation Rate'
    from trips t
    where request_at between '2013-10-01' and '2013-10-03'
    and EXISTS (select '1' from users
    where users_id =t.client_id
    and banned ='No'
    )
    group by request_at


  • 0
    E

    EXISTS seems twice faster than JOIN. my solution with JOIN took 229 ms. Voted for your one


  • 0
    N

    SELECT Request_at as Day, ROUND (SUM(CASE
    WHEN Status like "%cancelled%" THEN 1
    ELSE 0
    END) / count(client_id),2 ) as "Cancellation_Rate"
    from Trips
    where request_at between date('2013-10-01') and date ('2013-10-03')
    and client_id in (select users_id from Users where role="client" and banned="No")
    group by Request_at;


Log in to reply
 

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