Return
departments.name — department nameCOUNT(employees.id) — number of employees in the departmentAVG(employees.salary) — average salary in the department
Only include departments with 3 or more employees. Order the results by average salary descending.Expected output
| name | COUNT(e.id) | AVG(e.salary) |
|---|---|---|
| 2 rows — values hidden, that's the puzzle | ||
Your query should return 2 rows with these columns. Your column aliases don't need to match.
departments
| id | name |
|---|---|
| 1 | Engineering |
| 2 | Sales |
| 3 | Marketing |
| 4 | Operations |
employees
| id | name | department_id | manager_id | salary | hired_on |
|---|---|---|---|---|---|
| 1 | Ana Reyes | 1 | NULL | 150000 | 2018-03-01 |
| 2 | Ben Cho | 1 | 1 | 120000 | 2019-06-15 |
| 3 | Cara Diaz | 1 | 1 | 120000 | 2020-01-20 |
| 4 | Dan Ellis | 2 | NULL | 140000 | 2017-11-05 |
| 5 | Eve Fox | 2 | 4 | 95000 | 2021-02-10 |
0 of 3 hints revealed
Submit an attempt first.