SQLSQL
#28

Immediate Food Delivery Rate on First Orders in SQL

MediumSwiggy
Interview Question #28
Asked at Swiggy

If customer preferred delivery date matches order date, the order is 'immediate'; otherwise 'scheduled'. Find the percentage of immediate orders among the first orders of all customers, rounded to 2 decimal places.

Input Table: delivery
3 rows preview
delivery_idcustomer_idorder_datecustomer_pref_delivery_date
112026-08-012026-08-02
222026-08-022026-08-02
312026-08-112026-08-11
Expected Output Structure1 rows
immediate_percentage
50
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us