Company: Eternal (Zomato)

Difficulty: medium

Problem Statement

Orders Far Beyond Their Month's Average Delivery Delay A food-delivery platform tracks every order in the SQLite table orders : CREATE TABLE orders ( id INTEGER PRIMARY KEY, customer_id TEXT NOT NULL, order_date TEXT NOT NULL, -- 'YYYY-MM-DD' expected_delivery_date TEXT NOT NULL, -- 'YYYY-MM-DD' actual_delivery_date TEXT NOT NULL -- 'YYYY-MM-DD' ); The delay of an order is the whole number of days between its promised and its real delivery: delay = actual_delivery_date - expected_delivery_date Every order is grouped into the calendar month in which it was placed , that is the year and month of its order_date . For each such month, avg_delay is the average delay of all orders placed in that month, rounded to the nearest whole number of days (a value exactly halfway up, e.g. 12.5 becomes 13 ). Write a SQL query that reports every order whose own delay is strictly greater than 5 times the avg_delay of the month the order was placed in . Return exactly th

More Eternal (Zomato) OA questionsInterview experiences