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 Seattle Sitters by Repeat Rate
00:00
5 left

Top Seattle Sitters by Repeat Rate

MediumSQL · PostgreSQL

Problem

Business Context

You’re working on analytics for a pet-sitting marketplace (think Rover-scale) with millions of bookings per year across major US cities. The Seattle operations team is rolling out a loyalty program and wants to identify the sitters who drive the most repeat business—because repeat bookings correlate strongly with higher lifetime value and lower customer acquisition costs.

In this marketplace, a repeat booking is defined as a pet owner booking the same sitter more than once (across different bookings). The team wants a leaderboard of the best-performing sitters in Seattle by repeat booking rate, with ties broken deterministically.

Task

Write a SQL query to find the top 10 sitters in Seattle based on repeat booking rate.

Requirements

  1. Consider only bookings where the sitter’s city = 'Seattle'.
  2. Consider only bookings with status = 'completed' (ignore cancelled/refunded).
  3. Define repeat booking rate per sitter as:
    • repeat_booking_rate = (number of completed bookings that are repeats) / (total completed bookings)
    • A booking is a repeat if it is not the first completed booking for that (owner_id, sitter_id) pair.
  4. Return these columns:
    • sitter_id, sitter_name, total_completed_bookings, repeat_completed_bookings, repeat_booking_rate
  5. Order results by:
    • repeat_booking_rate DESC,
    • then total_completed_bookings DESC,
    • then sitter_id ASC.
  6. Return only the top 10 rows.

Schema

sitters
ColumnTypeDescription
sitter_idPKINTUnique identifier for the sitter
sitter_nameVARCHAR(100)Sitter display name
cityVARCHAR(100)Primary city where the sitter operates
created_atTIMESTAMPTimestamp when the sitter joined
bookings
ColumnTypeDescription
booking_idPKBIGINTUnique identifier for the booking
owner_idBIGINTUnique identifier for the pet owner
sitter_idINTSitter who fulfilled the booking (FK to sitters)
start_dateDATEStart date of the booking
end_dateDATEEnd date of the booking
statusVARCHAR(20)Booking status (completed, cancelled, refunded, etc.)
booked_atTIMESTAMPTimestamp when the booking was created
Tablessittersbookings
Interviewer

Your question is Top Seattle Sitters by Repeat Rate. Start with the requirements and the two 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.