w3resource
SQL exercises

SQL Subquery Exercises: Identify all the employees who earn more than the average and who work in any of the IT departments

SQL SUBQUERY: Exercise-28 with Solution

Write a query to identify all the employees who earn more than the average and who work in any of the IT departments.

Sample table: employees


Sample table: departments


Sample Solution:

SELECT last_name 
FROM employees 
WHERE department_id IN 
(SELECT department_id 
FROM departments 
WHERE department_name LIKE 'IT%') 
AND salary > 
(SELECT avg(salary) 
FROM employees);

Sample Output:

last_name
Hunold

Practice Online


Query Visualization:

Duration:

Query visualization of Identify all the employees who earn more than the average and who work in any of the IT departments - Duration

Rows:

Query visualization of Identify all the employees who earn more than the average and who work in any of the IT departments - Rows

Cost:

Query visualization of Identify all the employees who earn more than the average and who work in any of the IT departments - Cost

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query that will identify all employees who work in departments located in the United Kingdom.
Next: Write a query to determine who earns more than Mr. Ozer.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming