Faster than 99.29% using MySQL Windowing functions (with detailed explanation)
Runtime: 457 ms, faster than 99.29% of MySQL online submissions for Department Highest Salary.\nMemory Usage: 0B, less than 100.00% of MySQL online submissions 
Runtime: 457 ms, faster than 99.29% of MySQL online submissions for Department Highest Salary.\nMemory Usage: 0B, less than 100.00% of MySQL online submissions for Department Highest Salary.\n\nExplanation: I\'m using concept of Windowing, which is [well supported by MySQL](https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html). Together with Windowing I\'m using [`RANK()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_rank) function, which ranks all the salaries grouped by `e.departmentId` (`PARTITION BY e.departmentId`) and the rank is calculated descending based on the salary value (`ORDER BY e.salary DESC`). We could, of course, use [`DENSE_RANK()`](https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_dense-rank).\n\nChacteristing of `RANK()` is that if two or more values have the same rank (1st in our case), they will have the same value, therefore we can select them safely in the final `SELECT` using `WHERE sr.srank = 1`.\n\nNotes:\n\n1. I like to name columns explicitly, so there is no "figuring out" how the column is named and from where does it come from, hence the additional code.\n2. I prefer to use `WITH` (so called [`Common Table Expressions`](https://dev.mysql.com/doc/refman/8.0/en/with.html)) instead of nested queries. Why? Code is more readable, easier to understand, easier to maintain and develop. It\'s also reflecting more how we think from a perspective of preparing data for a final `SELECT`, breaking subqueries into logical steps. It especially works with longer queries.\n\n```sql\n# Write your MySQL query statement below\nWITH salaries_ranked AS (\n    SELECT\n        e.departmentId id,\n        e.name name,\n        e.salary salary,\n        RANK() OVER(\n            PARTITION BY e.departmentId\n            ORDER BY e.salary DESC\n        ) srank\n    FROM Employee e\n)\nSELECT\n    d.name Department,\n    sr.name Employee,\n    sr.salary\nFROM salaries_ranked sr\nJOIN Department d ON d.id = sr.id\nWHERE sr.srank = 1;\n```
['Sliding Window', 'MySQL']