Clear Solution
-- We can write an inner query to get max salary department wise. \n-- After that we can use that result and join it with employee and department\n-- to get dep
-- We can write an inner query to get max salary department wise. \n-- After that we can use that result and join it with employee and department\n-- to get department name, employee name and max salary. \n\n/* Write your T-SQL query statement below */\n```\nselect d.name Department, emp.name Employee, temp.salary Salary from \n(select dept.id as deptid, max(emp.salary) as salary\nfrom employee emp inner join department dept\non emp.departmentId = dept.id\ngroup by dept.id) temp\ninner join employee emp on emp.departmentId = temp.deptid\nand temp.salary = emp.salary\ninner join Department d on d.id = temp.deptid\n```\n\n-- --Other possible solutions\n```\n-- SELECT D.Name,A.Name,A.Salary \n-- FROM \n-- \tEmployee A,\n-- \tDepartment D   \n-- WHERE A.DepartmentId = D.Id \n--   AND NOT EXISTS \n--   (SELECT 1 FROM Employee B WHERE B.Salary > A.Salary AND A.DepartmentId = B.DepartmentId) \n```\n-- -- \n```\n-- SELECT D.Name AS Department ,E.Name AS Employee ,E.Salary \n-- from \n-- \tEmployee E,\n-- \tDepartment D \n-- WHERE E.DepartmentId = D.id \n--   AND (DepartmentId,Salary) in \n--   (SELECT DepartmentId,max(Salary) as max FROM Employee GROUP BY DepartmentId)\n ```
[]