Search ⌘K
Airbnb
Airbnb

Interview Core Track · Easy · 15 min

6. Find the Average Number of Guests per Booking in Each City for Airbnb

As an analyst at Airbnb, one of the most useful insights you could provide would be to understand the average number of guests per booking across locations. ...

Interview Core Track
Easy
15 min
joins
aggregation

Company labels are directional practice context, not official interview guidance.

Timer 00:00
Back to practice

Objective

Practice joins through a Airbnb-tagged business scenario.

Approach

Use this track to improve speed, edge-case handling, and accuracy under timed conditions.

Company context

Company labels are directional practice context, not official interview guidance.

Prereq: query basics
Prereq: filtering

As an analyst at Airbnb, one of the most useful insights you could provide would be to understand the average number of guests per booking across locations. For this question, we would like you to write a SQL query that will find the average number of guests per booking in each city. bookings **Example Input:** booking_id property_id guests booking_date ------------------------------------------------ 101 4523 3 01/01/2022 102 9871 2 01/05/2022 103 4523 4 02/10/2022 104 7452 1 02/20/2022 105 9871 3 03/01/2022 properties **Example Input:** property_id city ------------------------- 4523 New York 9871 Los Angeles 7452 Chicago **Example Output:** city average_guests ----------------------------- New York 3.5 Los Angeles 2.5 Chicago 1.0 **Answer:** SELECT p.city, AVG(b.guests) AS average_guests FROM bookings b JOIN properties p USING(property_id) GROUP BY 1 ---

properties
property_id INT PRIMARY KEY
city VARCHAR(100
bookings
booking_id INT PRIMARY KEY
property_id INT REFERENCES properties(property_id
Editor
SQL workspace

Run queries against the protected question data, then submit once the result shape looks right.

Sign in to run SQL

Create a free account or sign in before running queries against protected question data.