SQL
All Top 50 SQL Interview Questions#28
Immediate Food Delivery Rate on First Orders in SQL
MediumSwiggyInterview Question #28
Asked at SwiggyIf 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_id | customer_id | order_date | customer_pref_delivery_date |
|---|---|---|---|
| 1 | 1 | 2026-08-01 | 2026-08-02 |
| 2 | 2 | 2026-08-02 | 2026-08-02 |
| 3 | 1 | 2026-08-11 | 2026-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.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.