Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Departments with Above-average Salaries | Subqueries in Human Resources
Subqueries in SQL

bookChallenge: 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.

Oppgave

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øsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Can you show me the SQL query to find departments with above-average salaries?

How do subqueries help in comparing department averages to the company average?

Can you explain how to structure the subquery for this scenario?

close

bookChallenge: Departments with Above-average Salaries

Sveip for å vise menyen

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.

Oppgave

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øsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 4
single

single

some-alt