Table 1: bookings
When someone makes a reservation on Airbnb.
col_name | col_type --------------+------------------- date | date booking_id | bigint listing_id | bigint
Structured practice, realistic datasets, and focused execution loops to help you perform with clarity in technical interviews.
230+
Interview-style coding questions
23+
Company-focused question sets
4
Practice engines: Postgres, MySQL, Python, R
| User | Score |
|---|---|
|
#1
Blake
Gold
|
105 pts
|
|
#2
Sydney
Silver
|
66 pts
|
|
#3
Greg
Bronze
|
60 pts
|
|
#4
Deeptarka
|
56 pts
|
|
#5
421
|
55 pts
|
|
#6
Juan Andrés
|
50 pts
|
|
#7
shweta
|
47 pts
|
|
#8
Michaela
|
42 pts
|
|
#9
Marieke
|
38 pts
|
|
#10
Margareta
|
38 pts
|
Anonymous Playground
Run SQL, Python, or R directly on this page. You can practice this sample without logging in.
Question 118
Table 1: bookings
When someone makes a reservation on Airbnb.
col_name | col_type --------------+------------------- date | date booking_id | bigint listing_id | bigint
Table 2: dates
Calendar dates from 01/01/2019 to 12/31/2025.
col_name | col_type ----------+---------- year | smallint month | smallint date | date
Table 3: listings
When a new Airbnb listing is created in a country ('US', 'UK', 'JP', 'CA', 'AU', 'DE')
col_name | col_type --------------+------------------- listing_id | bigint country | varchar(2) created_dt | date
Sample results
date | count ------------+------- 2021-07-01 | 1 2021-07-02 | 2 2021-07-03 | 3 2021-07-04 | 0 2021-07-05 | 5
Official solution
POSTGRESWITH us_bookings AS (
SELECT
B.date,
COUNT(booking_id) AS num_bookings
FROM bookings B
INNER JOIN listings L
ON L.listing_id = B.listing_id
AND L.country = 'US'
GROUP BY date
)
SELECT
D.date,
CASE WHEN B.num_bookings IS NULL THEN 0 ELSE B.num_bookings END AS num_bookings
FROM dates D
LEFT JOIN us_bookings B
ON B.date = D.date
WHERE D.date >= '2021-07-01'
AND D.date < '2021-08-01'
ORDER BY D.date;
This query is designed to count the number of bookings made in US listings for each date within the specified time range. It accomplishes this by first selecting all bookings made in US listings and grouping them by date. This subquery is named "us_bookings".
The main query then selects all dates within the specified time range and left joins them with the "us_bookings" subquery on the date field. This is done to ensure that all dates within the specified range are included in the result, even if there were no bookings made on that date.
The final select statement returns the date and the number of bookings made on that date, with a case statement to handle cases where there were no bookings made on a particular date.
The result is ordered by date.
Expected results
Expected results appear after you submit.
Your results
Pick a lane, execute daily, and build interview confidence through repetition.
Track 01
Practice easy to hard questions with immediate feedback and structured progression.
Open
Track 02
Write queries and scripts against realistic business tables in your preferred engine.
Open
Track 03
Follow curated paths that map directly to data analyst, scientist, and engineer interviews.
Open
Track 04
Simulate interview pressure and sharpen how you explain your approach.
Open
Value Calculator
Enter your current salary and compare potential compensation upside against your SQLPad plan investment.
Summary
SQLPad starts at only $79/mo
Estimated annual upside
$0/year
Estimated ROI
0%
This salary estimate is based on publicly available compensation data for data scientists at top U.S. tech firms. Outcomes vary by interview performance, location, and hiring urgency.
Data engineers and machine learning engineers often earn more, so ROI can be higher for engineering-focused roles.
Ready to Begin
Use SQLPad consistently and turn interview prep into a structured system instead of a guessing game.