SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Average Vacant Nights in 2025

Unsolved

Airbnb wants to know how many nights an active listing typically sits empty. A booking occupies every night from check_in up to but not including check_out. Only nights between 2025-01-01 and 2025-12-31 count, so bookings that cross into or out of 2025 contribute only their 2025 nights. A listing's vacant nights are 365 minus its booked 2025 nights; bookings for the same listing never overlap. Active listings (is_active = 1) with no bookings are vacant all 365 nights, and inactive listings are ignored. Write an SQL query that returns a single column, avg_vacant_nights: the average vacant nights across active listings, rounded to the nearest whole number.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Airbnb

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM listings
Full source dataset
4 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine