🔥 SQL Interview Question of the Day
📌 Scenario:
A food delivery company wants to find the average delivery time taken by each city.
You have one table:
deliveries
• delivery_id
• customer_id
• city
• order_time
• delivery_time
☑ Solution:
SELECT
city,
AVG(
TIMESTAMPDIFF(MINUTE, order_time, delivery_time)
) AS avg_delivery_time
FROM deliveries
GROUP BY city
ORDER BY avg_delivery_time;
💡 Concept Tested:
GROUP BY + Date Time Functions + Aggregate Functions
(Calculating Performance Metrics From Time-Based Data)
❤️ React if you want more SQL interview questions.
Post #2414
1.25K
- 👍 3
- ❤ 2