Trips and the Users

ASKED IN INTERVIEW
10pts
Uber

Problem Statement

Calculate the daily cancellation rate of requests with unbanned users (both client and driver must not be banned) between 2024-01-01 and 2024-01-03.

Rules:

  • Output columns: day, cancellation_rate.
  • cancellation_rate = (Canceled by Client or Driver) / Total Requests.
  • Exclude all trips where either the Client or Driver is Banned.
  • Round to 2 decimal places.
  • Sort by day in ascending order.
Tests your understanding of
Filtering, Joins and Ratios

Input Tables

trips
trip_id(INTEGER)client_id(INTEGER)driver_id(INTEGER)status(VARCHAR)request_at(DATE)
1110completed2024-01-01
2211cancelled_by_driver2024-01-01
3312completed2024-01-02
4112cancelled_by_client2024-01-02
5210completed2024-01-03
users
users_id(INTEGER)banned(VARCHAR)role(VARCHAR)
1Noclient
2Yesclient
3Noclient
10Nodriver
11Nodriver
12Nodriver
drivers
driver_id(INTEGER)rating(DECIMAL)
104.8

Expected Output

day(DATE)cancellation_rate(DECIMAL)
2024-01-010
2024-01-020.5

Tags

HardASKED IN INTERVIEWFilteringJoinsRatios
30-40 min
36%

Hints