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
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