empId empSalary empDept 1 45000 IT 2 40000 IT 3 50000 SALES 4 60000 SALES 5 75000 IT 6 80000 IT 7 25000 OPS 8 30000 OPS 9 55000 MARKETING 10 60000 MARKETING
select empId where empSalary > avg(empSalary) for each empDept
select empId from tbl t1 where empSalary > (select AVG(empSalary) from tbl t2 m where t1.empDept =t2.empDept )
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)