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
Top Performers by Department Query
00:00
5 left

Top Performers by Department Query

MediumSQL · PostgreSQL

Problem

Unum's Data Science team wants a department-level view of its strongest active employees. Write a PostgreSQL query that combines employee, review, and performance outcome data to rank performers within each department.

Requirements

  1. Include only active employees assigned to a department and having at least one non-null review score.
  2. Calculate each employee's average review score and average performance outcome score.
  3. Calculate a performance score using 70% of the average review score and 30% of the average outcome score. Treat missing outcome scores as zero.
  4. Rank employees independently within each department and return the top three, using employee ID as a deterministic tie-breaker.
  5. Return department name, employee name, both averages, the calculated performance score, and the employee's rank.

Schema

departments
ColumnTypeDescription
department_idPKINTEGERUnique department identifier
department_nameVARCHAR(100)Department name
employees
ColumnTypeDescription
employee_idPKINTEGERUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
department_idINTEGERAssigned department identifier
employment_statusVARCHAR(20)Current employment status
performance_reviews
ColumnTypeDescription
review_idPKINTEGERUnique review identifier
employee_idINTEGEREmployee being reviewed
review_periodVARCHAR(20)Review period label
review_scoreNUMERIC(5,2)Review score
performance_results
ColumnTypeDescription
result_idPKINTEGERUnique outcome record identifier
employee_idINTEGEREmployee associated with the outcome
performance_periodVARCHAR(20)Outcome period label
outcome_scoreNUMERIC(5,2)Measured performance outcome score
Tablesdepartmentsemployeesperformance_reviewsperformance_results
Interviewer

Your question is Top Performers by Department Query. 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.