Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Top Cities Booking Conversion SQL
00:00
5 left

Top Cities Booking Conversion SQL

MediumSQL · PostgreSQL

Problem

Airbnb wants to identify the cities with the strongest recent search-to-booking conversion. Write a SQL query that calculates booking conversion by city for the 30-day period ending on September 16, 2026.

A booking counts toward a city only when it is associated with a search session for that city. Count distinct search sessions and distinct booked sessions, so multiple booking records for one session do not inflate conversion.

Output

  1. Return one row per city with at least one qualifying search session.
  2. Include city_name, search_sessions, booked_sessions, and conversion_rate.
  3. conversion_rate is booked sessions divided by search sessions, rounded to four decimal places.
  4. Sort by conversion rate descending, then city name ascending, and return the top three rows.
  5. Sessions and bookings outside the fixed 30-day period are excluded. Cities or sessions with NULL city or session identifiers do not contribute to the city results.

Schema

cities
ColumnTypeDescription
city_idPKINTUnique city identifier
city_nameVARCHAR(100)City name displayed in the report
countryVARCHAR(100)Country containing the city
search_sessions
ColumnTypeDescription
session_idPKINTUnique Airbnb search session identifier
city_idINTCity searched by the guest
searched_atTIMESTAMPTimestamp when the search occurred
bookings
ColumnTypeDescription
booking_idPKINTUnique booking event identifier
session_idINTSearch session associated with the booking
booked_atTIMESTAMPTimestamp when the booking occurred
Tablescitiessearch_sessionsbookings
Interviewer

Your question is Top Cities Booking Conversion SQL. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.