AnalystPath

Department vs Company Pay Benchmark

SQLMediumMid level~15 min

Problem

**[Widely asked at FAANG companies]**

For each department, compare its average salary against the **overall company average**.
Label each department as:
- `'higher'` if dept avg > company avg
- `'lower'` if dept avg < company avg
- `'same'` if they are equal

Return `dept_id`, `dept_avg`, `company_avg`, and `comparison`,
ordered by dept_id.

Tables

Example rows — the live problem includes the full dataset.

employees
emp_idnamedept_idsalary

Expected output

Your answer should return 3 rows with the columns dept_id, dept_avg, company_avg, comparison.

Starter code (SQL)

SELECT *
FROM employees;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions