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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
Debugging Complex SQL
00:00
5 left

Debugging Complex SQL

MediumSQL · PostgreSQL

Problem

What is your process for debugging or optimizing complex SQL queries?

Use the provided interview data to demonstrate a reliable query for candidate interview metrics. The result should include only candidates with at least one completed interview that has a non-NULL evaluation score. Rows with a NULL average score are ignored.

Output

  1. One row per qualifying candidate with candidate_id, candidate_name, completed_interviews, average_score, last_completed_date, and review_status
  2. Sort by completed interviews descending, average score descending, then candidate ID ascending

Schema

candidates
ColumnTypeDescription
candidate_idPKINTUnique candidate identifier
candidate_nameVARCHAR(100)Candidate full name
interviews
ColumnTypeDescription
interview_idPKINTUnique interview identifier
candidate_idINTCandidate interviewed
scheduled_atTIMESTAMPScheduled interview timestamp
statusVARCHAR(30)Interview lifecycle status
evaluations
ColumnTypeDescription
evaluation_idPKINTUnique evaluation identifier
interview_idINTInterview being evaluated
scoreNUMERIC(5,2)Evaluation score from 0 to 100
evaluated_atTIMESTAMPEvaluation creation timestamp
Tablescandidatesinterviewsevaluations
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.