Data Analysis Books | Python | SQL | Excel | Artificial Intelligence | Power BI | Tableau | AI Resources: post #2175 โ€” TG.ME

๐Ÿš€ Real SQL Interview Question Reported in a Swiggy Business Analyst Interview

Question:

Given an orders table with the following columns:

driver_id
order_time
delivered_time

Write an SQL query to calculate the average waiting/delivery time (in minutes) for each delivery partner.

โœ… SQL Solution (MySQL)

SELECT
driver_id,
AVG(TIMESTAMPDIFF(MINUTE, order_time, delivered_time)) AS avg_delivery_time
FROM orders
GROUP BY driver_id;

๐Ÿ’ก Approach:

โ€ข Calculate the time difference between order_time and delivered_time.
โ€ข Convert the difference into minutes using TIMESTAMPDIFF().
โ€ข Group records by driver_id.
โ€ข Use AVG() to find the average delivery time for each delivery partner.

๐Ÿ“š Concepts Tested:

โ€ข Date & Time Functions
โ€ข GROUP BY
โ€ข Aggregate Functions (AVG)
โ€ข Business Metrics

React โ™ฅ๏ธ for more real interview questions
โค8
August 16, 2026 3.3K 3