Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Employees With More Than Average Salary | Nested Subqueries
Intermediate SQL
course content

Kursusindhold

Intermediate SQL

Intermediate SQL

1. Grouping
2. Nested Subqueries
3. Joining Tables
4. DDL and DML in SQL

book
Challenge: Employees With More Than Average Salary

When a subquery is written in the WHERE section, we can use the IN operator and comparison operators:

sql
Opgave

Swipe to start coding

Find employees whose salary is above the average salary of all employees using a subquery in the WHERE section.

The resulting table should have 3 columns: first_name, last_name, and salary. Then, sort the result by salary from highest to lowest using ORDER BY.

Note

This syntax can be used as a great alternative to the HAVING clause.

Brief Instructions

  • Retrieve the first_name, last_name, and salary columns from the employees table.
  • In the WHERE clause, use an inner query with the syntax salary > [inner query].
  • In the inner query, get the average value of the salary column from the employees table.
  • Sort the results by salary in descending order.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 4
toggle bottom row

book
Challenge: Employees With More Than Average Salary

When a subquery is written in the WHERE section, we can use the IN operator and comparison operators:

sql
Opgave

Swipe to start coding

Find employees whose salary is above the average salary of all employees using a subquery in the WHERE section.

The resulting table should have 3 columns: first_name, last_name, and salary. Then, sort the result by salary from highest to lowest using ORDER BY.

Note

This syntax can be used as a great alternative to the HAVING clause.

Brief Instructions

  • Retrieve the first_name, last_name, and salary columns from the employees table.
  • In the WHERE clause, use an inner query with the syntax salary > [inner query].
  • In the inner query, get the average value of the salary column from the employees table.
  • Sort the results by salary in descending order.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 4
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt