SQLite Exercise: Find the names, the salary of the employees whose salary is greater than the average salary
Write a query to find the names (first_name, last_name), the salary of the employees whose salary is greater than the average salary.
Sample table : employees
SQLite Code:
SELECT first_name, last_name, salary FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);
Output:
first_name last_name salary ---------- ---------- -------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000 Alexander Hunold 9000 Nancy Greenberg 12000 Daniel Faviet 9000 John Chen 8200 Ismael Sciarra 7700 Jose Manue Urman 7800 Luis Popp 6900 Den Raphaely 11000 Matthew Weiss 8000 Adam Fripp 8200 Payam Kaufling 7900 Shanta Vollman 6500 John Russell 14000 Karen Partners 13500 Alberto Errazuriz 12000 Gerald Cambrault 11000 Eleni Zlotkey 10500 Peter Tucker 10000 David Bernstein 9500 Peter Hall 9000 Christophe Olsen 8000 Nanette Cambrault 7500 Oliver Tuvault 7000 Janette King 10000 Patrick Sully 9500 Allan McEwen 9000 Lindsey Smith 8000 Louise Doran 7500 Sarath Sewall 7000 Clara Vishney 10500 Danielle Greene 9500 Mattea Marvins 7200 David Lee 6800 Lisa Ozer 11500 Harrison Bloom 10000 Tayler Fox 9600 William Smith 7400 Elizabeth Bates 7300 Ellen Abel 11000 Alyssa Hutton 8800 Jonathon Taylor 8600 Jack Livingston 8400 Kimberely Grant 7000 Michael Hartstein 13000 Susan Mavris 6500 Hermann Baer 10000 Shelley Higgins 12000 William Gietz 8300
Practice SQLite Online
Model Database
Structure of 'hr' database :

Improve this sample solution and post your code through Disqus.
Previous: Write a query to find the names (first_name, last_name) of the employees who are managers.
Next: Write a query to find the names (first_name, last_name), the salary of the employees whose salary is equal to the minimum salary for their job grade.
What is the difficulty level of this exercise?
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook