EmpID Name Department Salary 1 A IT 5000 2 B IT 4000 3 C QA 4000 4 D SS 8000 5 E IT 10000 6 F QA 4500
SELECT Employee.* FROM Employee INNER JOIN ( SELECT Department, MAX(Salary) AS TopSalary FROM Employee GROUP BY Department) AS DepartmentSalaries ON Employee.Department = DepartmentSalaries.Department AND Employee.Salary = DepartmentSalaries.TopSalary
ROW_NUMBER()
SELECT EmpID, Name, Department, Salary FROM ( SELECT EmpID, Name, Department, Salary, ROW_NUMBER() OVER(Partition By Department ORDER BY Salary DESC) AS RowNo FROM Employee ) AS T WHERE RowNo=1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)