Welcome to the SQL screen.
The question is on your right: Top Departments by Average Salary. Read through the requirements and the two tables first.
Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?
You are given employee and department data from an internal people analytics system. Write a PostgreSQL query to return the top three departments with the highest average employee salary, excluding departments that have fewer than five employees. The result should include the department name, employee count, and average salary, sorted by average salary from highest to lowest.
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique identifier for a department |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique identifier for an employee |
| employee_name | VARCHAR(100) | Employee full name |
| department_id | INT | Department assigned to the employee |
| salary | DECIMAL(10,2) | Employee salary |