
SQL Subquery Exercises: Display the employee id, employee name for all employees who earn more than the average salary
SQL SUBQUERY: Exercise-4 with Solution
Write a query to display the employee id, employee name (first name and last name ) for all employees who earn more than the average salary.
Sample table: employees
Sample Solution:
SELECT employee_id, first_name,last_name
FROM employees
WHERE salary >
( SELECT AVG(salary)
FROM employees
);
Sample Output:
employee_id first_name last_name 100 Steven King 101 Neena Kochhar 102 Lex De Haan 103 Alexander Hunold 108 Nancy Greenberg 109 Daniel Faviet 110 John Chen 111 Ismael Sciarra 112 Jose Manuel Urman 113 Luis Popp 114 Den Raphaely 120 Matthew Weiss 121 Adam Fripp 122 Payam Kaufling 123 Shanta Vollman 145 John Russell 146 Karen Partners 147 Alberto Errazuriz 148 Gerald Cambrault 149 Eleni Zlotkey 150 Peter Tucker 151 David Bernstein 152 Peter Hall 153 Christopher Olsen 154 Nanette Cambrault 155 Oliver Tuvault 156 Janette King 157 Patrick Sully 158 Allan McEwen 159 Lindsey Smith 160 Louise Doran 161 Sarath Sewall 162 Clara Vishney 163 Danielle Greene 164 Mattea Marvins 165 David Lee 168 Lisa Ozer 169 Harrison Bloom 170 Tayler Fox 171 William Smith 172 Elizabeth Bates 174 Ellen Abel 175 Alyssa Hutton 176 Jonathon Taylor 177 Jack Livingston 178 Kimberely Grant 201 Michael Hartstein 203 Susan Mavris 204 Hermann Baer 205 Shelley Higgins 206 William Gietz
Practice Online
Query Visualization:
Duration:

Rows:

Cost:

Contribute your code and comments through Disqus.
Previous: Write a query to display the name ( first name and last name ), salary, department id for those employees who earn such amount of salary which is the smallest salary of any of the departments.
Next: Write a query to display the employee name ( first name and last name ), employee id and salary of all employees who report to Payam.
What is the difficulty level of this exercise?
New Content: Composer: Dependency manager for PHP, R Programming