The cancellation rate is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.
Write a solution to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between "2013-10-01" and "2013-10-03". Round Cancellation Rate to two decimal points.
Return the result table in any order.
The result format is in the following example.
WITH ban AS (
SELECT users_id
FROM users
WHERE banned = 'No'
)
SELECT request_at AS Day
, ROUND(SUM(CASE WHEN status LIKE 'cancelled%' THEN 1 ELSE 0 END) / COUNT(*), 2) AS 'Cancellation Rate'
FROM trips
WHERE client_id IN (SELECT users_id from ban)
AND driver_id IN (SELECT users_id from ban)
AND request_at BETWEEN '2013-10-01' AND '2013-10-03'
GROUP BY request_at