1651. Hopper Company Queries III

https://leetcode.com/problems/hopper-company-queries-iii

Description

Table: Drivers

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| driver\_id   | int     |
| join\_date   | date    |
+-------------+---------+
driver\_id is the primary key for this table.
Each row of this table contains the driver's ID and the date they joined the Hopper company.

Table: Rides

+--------------+---------+
| Column Name  | Type    |
+--------------+---------+
| ride\_id      | int     |
| user\_id      | int     |
| requested\_at | date    |
+--------------+---------+
ride\_id is the primary key for this table.
Each row of this table contains the ID of a ride, the user's ID that requested it, and the day they requested it.
There may be some ride requests in this table that were not accepted.

Table: AcceptedRides

Write an SQL query to compute the average_ride_distance and average_ride_duration of every 3-month window starting from January - March 2020 to October - December 2020. Round average_ride_distance and average_ride_duration to the nearest two decimal places.

The average_ride_distance is calculated by summing up the total ride_distance values from the three months and dividing it by 3. The average_ride_duration is calculated in a similar way.

Return the result table ordered by month in ascending order, where month is the starting month's number (January is 1, February is 2, etc.).

The query result format is in the following example.

ac

Last updated

Was this helpful?