Immediate Food Delivery II

4pts
Door Dash

Problem Statement

In the DoorDash system, if a customer's preferred delivery date is the same as the order date, the order is called immediate; otherwise, it is called scheduled.

The first order of a customer is the order with the earliest order date that the customer has made. It is guaranteed that a customer has precisely one first order (no two orders on the same earliest day).

Write an SQL query to find the percentage of immediate orders in the first orders of all customers.

Rules:

  • The result should be rounded to 2 decimal places.
  • The result column should be named immediate_percentage.
  • Results must be returned as a single numerical value.
Tests your understanding of
Basic SQL, Aggregation, Subqueries and Filtering

Input Tables

delivery
delivery_id(INTEGER)customer_id(INTEGER)order_date(DATE)customer_pref_delivery_date(DATE)
112019-08-012019-08-01
222019-08-022019-08-02
312019-08-112019-08-12
432019-08-242019-08-24
532019-08-212019-08-22
622019-08-112019-08-13
742019-08-092019-08-09
842019-08-102019-08-10
952019-08-012019-08-01
1052019-08-052019-08-05
1162019-08-012019-08-02
1272019-08-012019-08-01

Expected Output

immediate_percentage(DECIMAL)
71.43

Tags

MediumBasic SQLAggregationSubqueriesFiltering
20-25 min
53%

Hints