How to find greater than average salary records in MySQL


Find the greater than average salary records in mysql by using AVG function. as per below example average salary is 5000

SELECT * FROM employee;

    id  name    salary  
------  ------  --------
     1  Ramesh      5000
     2  Ashish      4000
     3  Rahul       6000
     4  Vishal      7000
     5  Harsh       3000

Get the greater than average salary records in MySQL

SELECT * FROM employee WHERE salary > (SELECT AVG(salary) FROM employee);

Output ::

    id  name    salary  
------  ------  --------
     3  Rahul       6000
     4  Vishal      7000


Related

find the nth highest salary in mysql without limit
how to find duplicate records in MySQL query
How to use second index forcefully in MySQL
How to get total number of rows in MySQL table with and without count
Difference between where and having clauses