Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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

Employee Model  Database - w3resource online SQLite practice

Structure of 'hr' database :

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?