MySQL partition by with join solution with explaination
\nSELECT b.Name AS Department, a.Name AS Employee, Salary FROM\n(SELECT *, MAX(Salary) OVER(PARTITION BY DepartmentId) AS max_val\nFROM Employee) a\nJOIN Depart
```\nSELECT b.Name AS Department, a.Name AS Employee, Salary FROM\n(SELECT *, MAX(Salary) OVER(PARTITION BY DepartmentId) AS max_val\nFROM Employee) a\nJOIN Department b\nON a.DepartmentId = b.Id\nWHERE Salary = max_val;\n```\nLogic here: add a column to the original Employee table of max salary within that department (that is what over partition by do)\nThen we select the ones that match max with its value to filter out the people with max salary of his / her department\nThen we join on the Department table to get the require information
['MySQL']