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
Debugging a Complex SQL Issue
00:00
5 left

Debugging a Complex SQL Issue

HardSQL · PostgreSQL

Problem

Describe a time you used SQL to solve a complex data issue.

For this exercise, use the supplied shift, assignment, and payment tables to demonstrate a reconciliation query. Identify completed assignments where the recorded payment differs from the expected payment, including missing payment records.

Output

  1. One row per completed assignment with a payment discrepancy.
  2. Columns: assignment_id, worker_id, shift_date, expected_payment, recorded_payment, and discrepancy.
  3. Treat a missing payment as zero, order by shift_date ascending and assignment_id ascending.

Schema

shifts
ColumnTypeDescription
shift_idPKINTUnique shift identifier
shift_dateDATEDate of the shift
statusVARCHAR(20)Shift status
hourly_rateNUMERIC(8,2)Expected hourly payment rate
hours_workedNUMERIC(5,2)Hours worked on the shift
assignments
ColumnTypeDescription
assignment_idPKINTUnique assignment identifier
shift_idINTReferenced shift identifier
worker_idINTWorker identifier
payments
ColumnTypeDescription
payment_idPKINTUnique payment record identifier
assignment_idINTReferenced assignment identifier
amountNUMERIC(10,2)Payment amount
Tablesshiftsassignmentspayments
Interviewer

Your question is Debugging a Complex SQL Issue. 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.