Forum
Databases
SQL Server - List all the job groups who average salary exceeds that of managers.
Junior Member
List all the job groups who average salary exceeds that of managers.
List all the job groups who average salary exceeds that of managers.
Empno ename job manager hiredate salary deptno commission
7369 smith clerk 7902 12/1/1982 1200 20 null
7499 allen salesman 7698 2/20/1981 1501 30 null
7521 ward salesman 7698 2/22/1981 1600 30 160
7698 black manager 7999 5/1/1981 3850 30 385
7902 ford analyst 7566 12/1/1981 3000 10 300
7688 jones analyst 7698 10/10/2008 4500 10 450
7689 martin clerk 7698 12/12/2004 4525 20 453
7999 scott ceo null 1/1/2001 9999 30 1000
7466 tiger manager 7999 1/1/2004 6500 10 650
Last edited by debasisdas; 04-28-2009 at 10:58 AM .
Reason: formatted
Re: List all the job groups who average salary exceeds that of managers.
What is the code that you are working on ?
Contributing Member
Re: List all the job groups who average salary exceeds that of managers.
Hi Jai,
The query can be like
Select AvgSal, job from (
select avg(salary) AvgSal, job from [tablename] group by job
) as vw where job<>'manager'
and AvgSal > (Select Avg(Salary) from [tablename] where job='manager')
---V V---
Vikas Vaidya
Junior Member
Re: List all the job groups who average salary exceeds that of managers.
Select job,avg(salary)from employees where (avg(salary)>(select salary from employees where job=manager) and job not equals 'manager') group by job.
Junior Member
Re: List all the job groups who average salary exceeds that of managers.
Select job,avg(salary)from employees where (avg(salary)>(select salary from employees where job=manager) and job not equals 'manager') group by job;
Expert Member
Re: List all the job groups who average salary exceeds that of managers.
Select job, avgsal
From (Select Avg (sal) avgsal, job
From emp
Group By job),
(Select sal msal
From emp
Where job = 'MANAGER')
Where avgsal > msal And job != 'MANAGER'
Contributing Member
Re: List all the job groups who average salary exceeds that of managers.
select job, avg(sal ) from emp where job != "MANAGER" group by job
having avg(sal ) > ( select avg(sal) from emp where job = "MANAGER" )
Sponsored Ads
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules