I want the salary of all employees whose sal
(salary) is greater than the average salary of all employees, however I get the error "invalid use of group function". How can I use avg()
function in where
clause?
select sal
from emp
where sal> (avg(sal)) ;
Jayvee :
you may need to use subquery:\nselect sal \nfrom emp\nwhere sal> (select avg(sal) avgsal from emp) ;\n",
2021-06-05T10:47:08
Loupeznik :
You can't use AVG in WHERE clause like that. Try this query:\nSELECT sal FROM emp WHERE sal > (SELECT AVG(sal) FROM emp)\n",
2021-06-05T10:47:04