357. Find Missing Dates in Orders

Hard TCS Real-World Scenarios
Query Rules
  • The query columns and order must match the expected result schema.
  • NULL values should be handled appropriately where applicable.
  • The grader compares output values and sorting order to evaluate.

Schema Browser

Click a table's header to toggle expand/collapse.
locations
3 cols
departments
3 cols
employees
6 cols
orders
6 cols

Reference Solution

Expected SQL
WITH RECURSIVE date_range(d) AS (SELECT MIN(order_date) FROM orders UNION ALL SELECT DATE(d, '+1 day') FROM date_range WHERE d < (SELECT MAX(order_date) FROM orders)) SELECT d AS missing_date FROM date_range WHERE d NOT IN (SELECT DISTINCT order_date FROM orders);
SQL Editor
Ctrl+Enter to run
Console Output

Console Terminal

Write your query and click "Run Query" (Ctrl + Enter) to see results and testcase validation.