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
Get started
Tune SQL for Top Jobs per Recruiter
00:00
5 left

Tune SQL for Top Jobs per Recruiter

HardSQL · PostgreSQL

Problem

You need to optimize a slow-running query. What steps would you take?

Using the provided schema, write an efficient query that returns qualifying open jobs and explain how you would investigate and validate the optimization. Include only submitted applications created on or after 2026-01-01, and retain jobs with at least two such applications.

Output

  1. One row per qualifying job with job_id, title, recruiter_name, submitted_application_count, unique_candidate_count, latest_submission, and recruiter_rank
  2. Include only the top two jobs per recruiter, preserving ties
  3. Order by recruiter name, rank, and job ID

Output details

  • Rank jobs within each recruiter by submitted_application_count descending, then latest_submission descending, preserving rank ties.
  • Order recruiter_name, recruiter_rank, and job_id ascending, placing NULL recruiter_name values last.
  • Count only applications associated with an existing candidate record.
  • Count every qualifying application, while counting each candidate once for unique_candidate_count.

Schema

applications
ColumnTypeDescription
application_idPKINTApplication identifier
job_idINTReferenced job
candidate_idINTReferenced candidate
statusVARCHAR(20)Application status
created_atTIMESTAMPApplication creation timestamp
jobs
ColumnTypeDescription
job_idPKINTJob identifier
titleVARCHAR(100)Job title
recruiter_idINTAssigned recruiter
statusVARCHAR(20)Job status
candidates
ColumnTypeDescription
candidate_idPKINTCandidate identifier
candidate_nameVARCHAR(100)Candidate name
sourceVARCHAR(40)Candidate acquisition source
recruiters
ColumnTypeDescription
recruiter_idPKINTRecruiter identifier
recruiter_nameVARCHAR(100)Recruiter name
team_nameVARCHAR(60)Recruiting team
Tablesapplicationsjobscandidatesrecruiters
Interviewer

Your question is Tune SQL for Top Jobs per Recruiter. Start with the requirements and the four 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.