Challenge: Departments with Above-average Salaries
You are about to tackle a practical scenario where subqueries help you analyze salary data across departments. Imagine a company wants to know which departments pay above the company-wide average salary. To solve this, you will need to compare each department's average salary with the overall average salary for all employees. This challenge will deepen your understanding of subqueries for comparative analysis in SQL.
Swipe to start coding
Write a query to return the names of departments where the average salary of employees in that department is higher than the overall average salary across all employees.
- Use a subquery to calculate the overall average salary for all employees.
- Group employees by department and calculate the average salary for each department.
- Only include those departments where the department average salary is greater than the overall average salary.
- Return the department names.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Großartig!
Completion Rate verbessert auf 5.56
Challenge: Departments with Above-average Salaries
Swipe um das Menü anzuzeigen
You are about to tackle a practical scenario where subqueries help you analyze salary data across departments. Imagine a company wants to know which departments pay above the company-wide average salary. To solve this, you will need to compare each department's average salary with the overall average salary for all employees. This challenge will deepen your understanding of subqueries for comparative analysis in SQL.
Swipe to start coding
Write a query to return the names of departments where the average salary of employees in that department is higher than the overall average salary across all employees.
- Use a subquery to calculate the overall average salary for all employees.
- Group employees by department and calculate the average salary for each department.
- Only include those departments where the department average salary is greater than the overall average salary.
- Return the department names.
Lösung
Danke für Ihr Feedback!
single