MS SQL SERVER - Subqueries - CTE
\n\n# Subqueries \n\n/* Write your T-SQL query statement below */\nselect d.name Department  , e.name Employee ,salary Salary \nfrom employee e\njoin department
\n\n# Subqueries \n```\n/* Write your T-SQL query statement below */\nselect d.name Department  , e.name Employee ,salary Salary \nfrom employee e\njoin department d\non e.departmentId =d.id\nwhere salary = \n(select max(salary) from employee t where t.departmentId =e.departmentId )\n\n```\n# CTE \n```\nWITH emp as (\n  select Max(salary) as maxSalary, departmentId from Employee\n  group by\n  departmentId\n)\n\nselect e.name as Employee, e.salary as Salary, d.name as Department from Employee e \ninner join Department d\non d.id = e.departmentId\ninner join emp\non emp.maxSalary = e.salary and emp.departmentId = d.id\n```
['MySQL']