PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/TikTok

Find top-paid employee per department

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competency in SQL data manipulation, including aggregation, ranking, handling of duplicate and historical rows, tie semantics, and temporal data interpretation when determining the top-paid employee per department.

  • easy
  • TikTok
  • Data Manipulation (SQL/Python)
  • Data Scientist

Find top-paid employee per department

Company: TikTok

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Technical Screen

## Tables Assume the company stores employee compensation by department assignment. ### `employee_dept_salary` - `employee_id` INT - `employee_name` VARCHAR - `department_id` INT - `department_name` VARCHAR - `salary` NUMERIC - `effective_date` DATE (optional; if present, assume you want the most recent salary) Notes: - An employee **may appear in multiple departments** (e.g., matrix org or multiple assignments). - There may be multiple rows per `(employee_id, department_id)` (e.g., historical changes) unless otherwise stated. ## Task Write a SQL query to return the **top 1 highest-paid employee per department**. ### Output For each department, return: - `department_id`, `department_name` - `employee_id`, `employee_name` - `salary` ## Follow-ups 1. If an employee can have records in multiple departments, does that affect the result? Explain. 2. What *would* affect the result (e.g., ties, duplicates, history rows)? 3. If the query can return multiple employees due to ties, but you **only want one row per department**, how would you enforce that (define a deterministic tie-break)?

Quick Answer: This question evaluates a candidate's competency in SQL data manipulation, including aggregation, ranking, handling of duplicate and historical rows, tie semantics, and temporal data interpretation when determining the top-paid employee per department.

Related Interview Questions

  • Find high-value crypto users and top-CTR product - TikTok (easy)
  • Write monthly customer and sales SQL queries - TikTok (easy)
  • Count buggy vs non-buggy by employer - TikTok (Medium)
  • Select max-discount product per category - TikTok (Medium)
  • Write SQL for 7-day geo-localized revenue dashboard - TikTok (Medium)
TikTok logo
TikTok
Nov 8, 2025, 12:00 AM
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
1
0

Tables

Assume the company stores employee compensation by department assignment.

employee_dept_salary

  • employee_id INT
  • employee_name VARCHAR
  • department_id INT
  • department_name VARCHAR
  • salary NUMERIC
  • effective_date DATE (optional; if present, assume you want the most recent salary)

Notes:

  • An employee may appear in multiple departments (e.g., matrix org or multiple assignments).
  • There may be multiple rows per (employee_id, department_id) (e.g., historical changes) unless otherwise stated.

Task

Write a SQL query to return the top 1 highest-paid employee per department.

Output

For each department, return:

  • department_id , department_name
  • employee_id , employee_name
  • salary

Follow-ups

  1. If an employee can have records in multiple departments, does that affect the result? Explain.
  2. What would affect the result (e.g., ties, duplicates, history rows)?
  3. If the query can return multiple employees due to ties, but you only want one row per department , how would you enforce that (define a deterministic tie-break)?

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More TikTok•More Data Scientist•TikTok Data Scientist•TikTok Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.