MYSQL- Easy Solution - Window Function and CTE
\n# Code\n\nwith new as\n(select *, dense_rank() over(partition by departmentId order by salary desc) as rn from employee)\n\nselect d.name as department, new.n
\n# Code\n```\nwith new as\n(select *, dense_rank() over(partition by departmentId order by salary desc) as rn from employee)\n\nselect d.name as department, new.name as employee , salary from new\njoin department d on d.id=new.departmentId\nwhere rn=1\n```
['MySQL']