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
Query and Prepare Data
00:00
5 left

Query and Prepare Data

MediumSQL · PostgreSQL

Problem

How would you manipulate and query a dataset in Python or R to prepare it for analysis?

For this PostgreSQL exercise, express the preparation as a SQL query using the provided tables. Return one analysis-ready row per regular-season game from January 1 through March 31, 2025.

Output

  1. Columns: game_date, opponent, venue_name, attendance, tickets_sold, ticket_revenue, avg_ticket_price, and occupancy_status
  2. Include games without matching venue or ticket records, using zero or NULL where appropriate
  3. Sort by game_date ascending

Schema

games
ColumnTypeDescription
game_idPKINTUnique game identifier
game_dateDATEDate of the game
opponentVARCHAR(100)Opponent name
venue_idINTReferenced venue identifier
attendanceINTRecorded attendance
game_typeVARCHAR(30)Season or competition classification
venues
ColumnTypeDescription
venue_idPKINTUnique venue identifier
venue_nameVARCHAR(150)Venue name
capacityINTMaximum venue capacity
ticket_sales
ColumnTypeDescription
sale_idPKINTUnique ticket sale record
game_idINTReferenced game identifier
tickets_soldINTTickets sold in the record
revenueDECIMAL(12,2)Revenue generated by the sale record
Tablesgamesvenuesticket_sales
Interviewer

Your question is Query and Prepare Data. 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.