w3resource
SQL exercises

SQL Subquery Exercises: Display the employee number, name and job title for all employees whose salary is more than any average salary of any department

SQL SUBQUERY: Exercise-20 with Solution

Write a query to display the employee number, name( first name and last name ) and job title for all employees whose salary is more than any average salary of any department.

Sample table: employees


Sample Solution:

SELECT employee_id, first_name, last_name, job_id  
FROM employees  
WHERE salary > ALL  
( SELECT AVG(salary)  
FROM employees  
GROUP BY department_id 
);

Sample Output:

employee_id	first_name	last_name	job_id
100		Steven		King		AD_PRES

Practice Online


Query Visualization:

Duration:

Query visualization of Display the employee number, name and job title for all employees whose salary is more than any average salary of any department - Duration

Rows:

Query visualization of Display the employee number, name and job title for all employees whose salary is more than any average salary of any department - Rows

Cost:

Query visualization of Display the employee number, name and job title for all employees whose salary is more than any average salary of any department - Cost

Contribute your code and comments through Disqus.

Previous: Write a query to display the employee number, name( first name and last name ) and job title for all employees whose salary is more than any salary of those employees whose job title is PU_MAN. Exclude job title PU_MAN.
Next: Write a query to display the employee name( first name and last name ) and department for all employees for any existence of those employees whose salary is more than 3700.

What is the difficulty level of this exercise?



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