Find Salary Greater Than Average Salary in SQL Server

Hi Programmers,welcome to new article of ozanecare. this article i’ll write the queries to find out Salary Greater Than Average Salary in Microsoft SQL Server. let’s see the queries.

Table Data
Salary higher than average salary
Average salary of table

Directly Test below queries into Editor.

--Salary greater than average salary
SELECT * FROM EMP E1,
      (SELECT DEPTNO,AVG(SAL) AVG_SAL FROM EMP 
	   GROUP BY DEPTNO) E2
WHERE E1.DEPTNO = E2.DEPTNO  AND
      E1.SAL > E2.AVG_SAL;

--To select all records from table
SELECT * FROM EMP ;


--To find average salary
SELECT DEPTNO,AVG(SAL) AVG_SAL FROM EMP 
GROUP BY DEPTNO;

Happy Coding…Thanks.

Post Author: adama