Problem · Medium · 20 min
Teams above the average
- Medium
- Grouping and totals
- Subqueries
A company keeps its staff in the table staff.
| Column | Meaning |
|---|---|
id |
The number of the person. It is unique. |
name |
The name of the person. |
team |
The team of the person. |
salary |
The monthly salary in euros, as a whole number. |
The company average is the average salary of all people, where each person counts once.
Write one query that returns the teams whose average salary is higher than the company average. The columns are:
team: the name of the team.average_salary: the average salary of the team, rounded to 2 decimals withROUND.
Put the team with the highest average_salary first. If two teams have the same average_salary, sort them by team name.
Tasks
2 to do
Task 1, not checked yet. Return the right rows for the example data.
Task 2, not checked yet. Return the right rows for other data that you cannot see.
Task 1 of 2
Return the right rows for the example data.