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
SQL for Consecutive Theater Seats
00:00
5 left

SQL for Consecutive Theater Seats

MediumSQL · PostgreSQL

Problem

The Zulily app needs to recommend the best available seating block for a live shopping theater event. Write a PostgreSQL query that finds one block of consecutive available seats for a specified screening.

Requirements

  1. Consider only screening 101 and seats whose status is available.
  2. Treat seats as consecutive only within the same row and seat rank, where rank 1 is the best rank.
  3. Select the block with the best rank first, then the greatest number of consecutive seats, then the earliest row and starting seat as deterministic tie-breakers.
  4. Return the screening name, row, rank, starting seat, ending seat, and block length.

Schema

screenings
ColumnTypeDescription
screening_idPKINTUnique screening identifier
screening_nameVARCHAR(100)Name of the Zulily event or show
seat_inventory
ColumnTypeDescription
seat_idPKINTUnique seat inventory identifier
screening_idINTReferences screenings.screening_id
row_labelVARCHAR(10)Theater row label
seat_numberINTNumeric position within the row
seat_rankINTSeat quality rank, with 1 as the best rank
statusVARCHAR(20)Seat availability status
Tablesscreeningsseat_inventory
Interviewer

Your question is SQL for Consecutive Theater Seats. 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.