5 pts.
 SQL question
One table named as employee has 3 columns (name, salary, department). I need to retrieve the employees whose salary is greater than average salary of their department.

that is

name    salary   department

iioo      10000    Technical

aaaa    15000     HR

pppp    17000     HR

wwww    20000    Technical

 

I need to get employee details whose salary is greater than average salary of their department. kindly help me out



Software/Hardware used:
Sql server
ASKED: December 9, 2009  12:46 PM
UPDATED: December 15, 2009  2:16 PM

Answer Wiki:
You'll want something like this. <pre>select * from Employee join (select Department, avg(Salary) Salary FROM Employee group by Department) a on Employee.Department = a.Department and Employee.Salary > a.Salary</pre>
Last Wiki Answer Submitted:  December 10, 2009  9:37 am  by  Denny Cherry   64,550 pts.
All Answer Wiki Contributors:  Denny Cherry   64,550 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

We don’t do homework here.

Sorry.

 63,580 pts.

 

Hey – if you won’t do my homework, how about some us my housework? :-)

 5,205 pts.