Write a query to select the department that contains more than 5 five employee, get the department id and also the number of employees whose salary is more than 40,000?

 Posted by Kmandapalli on 1/22/2014 | Category: Sql Server Interview questions | Views: 687 | Points: 40
Answer:

SELECT DepartmentId, Count(*)
FROM Employee E, Department D
WHERE E.DepartmentId = D.DepartmentId
AND E.Salary > 40000
AND (SELECT DepartmentId FROM Employee
GROUP BY DepartmentId
HAVING COUNT(*) 5)


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response