Find restaurants with NO orders in the 30-day period 2026-10-02 to 2026-10-31 (inclusive). Orders after 2026-10-31 do not make a restaurant active. Return `restaurant_id`, `name`, `last_order_date` = the latest order on or before 2026-10-31 (NULL if none). Order by `restaurant_id`.
| Column | Type |
|---|---|
| restaurant_id | INTEGER |
| name | TEXT |
| city | TEXT |
| restaurant_id | name | city |
|---|---|---|
| 1 | Spice Route | Jaipur |
| 2 | Dosa Hut | Jaipur |
| 3 | Momo Point | Delhi |
| 4 | Biryani Bay | Delhi |
| 5 | Paratha Lane | Jaipur |
| Column | Type |
|---|---|
| order_id | INTEGER |
| restaurant_id | INTEGER |
| order_date | DATE |
| order_id | restaurant_id | order_date |
|---|---|---|
| 1 | 1 | 2026-10-15 |
| 2 | 1 | 2026-09-10 |
| 3 | 2 | 2026-09-25 |
| 4 | 3 | 2026-10-31 |
| 5 | 2 | 2026-08-01 |
| 6 | 5 | 2026-10-02 |
| restaurant_id | name | last_order_date |
|---|---|---|
| 2 | Dosa Hut | 2026-09-25 |
| 4 | Biryani Bay | NULL |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Job Postings Filled Within 30 Days · Category Share of Revenue ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.