We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
A medium sql problem, graded against 4 test cases (2 of them hidden).
Query-writing problems - joins, aggregation, window functions, and query tuning.
Reach for it when you see: A schema and a question about the data rather than a function signature.
More SQLproblems →```sql
SELECT day::date AS d
FROM generate_series($1::date, $2::date, INTERVAL '1 day') day
ORDER BY d;
```
MySQL 8+ / SQL Server (no generate_series):
```sql
WITH RECURSIVE dates AS (
SELECT CAST($1 AS DATE) AS d
UNION ALL
SELECT DATE_ADD(d, INTERVAL 1 DAY)
FROM dates
WHERE d < CAST($2 AS DATE)
)
SELECT d FROM dates ORDER BY d;
-- MySQL: SET cte_max_recursion_depth = 10000; if needed.
```
Common use: LEFT JOIN actual events to the spine to zero-fill missing days. Without the spine, days with no activity are dropped from charts.
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
These apply to the pattern as a whole, not just this problem.