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

Employees With More Than Average Salary ChallengeEmployees With More Than Average Salary Challenge

I mentioned earlier that when a subquery is written in the WHERE section, we can use the IN operator and comparison operators.

For example, like this:

Following a similar algorithm, you'll need to complete the following task.

We'll be working with the employees table, which looks like this:

employee_id first_name last_name department salary hire_date
1 John Doe Engineering 80000.00 2015-03-01T00:00:00Z
2 Jane Smith Engineering 90000.00 2017-08-15T00:00:00Z
3 Alice Johnson Marketing 75000.00 2016-11-10T00:00:00Z
4 Bob Brown Marketing 72000.00 2018-06-25T00:00:00Z
... ... ... ... ... ...
100 William Solis Sales 55000.00 2020-05-01T00:00:00Z

Task

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.

Everything was clear?

Section 2. Chapter 4
toggle bottom row
course content

Course Content

Intermediate SQL

Employees With More Than Average Salary ChallengeEmployees With More Than Average Salary Challenge

I mentioned earlier that when a subquery is written in the WHERE section, we can use the IN operator and comparison operators.

For example, like this:

Following a similar algorithm, you'll need to complete the following task.

We'll be working with the employees table, which looks like this:

employee_id first_name last_name department salary hire_date
1 John Doe Engineering 80000.00 2015-03-01T00:00:00Z
2 Jane Smith Engineering 90000.00 2017-08-15T00:00:00Z
3 Alice Johnson Marketing 75000.00 2016-11-10T00:00:00Z
4 Bob Brown Marketing 72000.00 2018-06-25T00:00:00Z
... ... ... ... ... ...
100 William Solis Sales 55000.00 2020-05-01T00:00:00Z

Task

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.

Everything was clear?

Section 2. Chapter 4
toggle bottom row
some-alt