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
From the following table, write a SQL query to find those employees who earn more than the average salary. Return employee ID, first name, last name.
Sample table: employees
SELECT employee_id, first_name,last_name FROM employees WHERE salary > ( SELECT AVG(salary) FROM employees );
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
Contribute your code and comments through Disqus.
Previous: From the following table, write a SQL query to find those employees whose salary matches the smallest salary of any of the departments. Return first name, last name and department ID.
Next: From the following table, write a SQL query to find those employees who report that manager whose first name is ‘Payam’. Return first name, last name, employee ID and salary.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
SQL: Tips of the Day
"where 1=1" statement?
It's usually when folks build up SQL statements.
When you add and value = "Toyota" you don't have to worry about whether there is a condition before or just WHERE.
- Exercises: Weekly Top 12 Most Popular Topics
- Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- SQL Exercises, Practice, Solution - SUBQUERIES
- C Programming Exercises, Practice, Solution : For Loop
- Python Exercises, Practice, Solution
- Python Data Type: List - Exercises, Practice, Solution
- C++ Basic: Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - exercises on Employee Database
- SQL Exercises, Practice, Solution - exercises on Movie Database
- SQL Exercises, Practice, Solution - exercises on Soccer Database
- C Programming Exercises, Practice, Solution : Recursion