✅Easiest Basic SQL Solution wiith table explanation( No advance)✅.
Explanation :\nStep 1: INNER JOIN\nThe INNER JOIN combines the relevant rows from both tables based on the common departmentId and id columns.\n\nResult after t
**Explanation :**\n*Step 1: INNER JOIN*\nThe INNER JOIN combines the relevant rows from both tables based on the common departmentId and id columns.\n\nResult after the INNER JOIN:\n![image](https://assets.leetcode.com/users/images/655e682b-7a61-46b7-b03d-1348cf2f0a0e_1706538575.3033745.png)\n\n*Step 2: WHERE Clause with Correlated Subquery*\nThe WHERE clause with the correlated subquery filters the rows to include only those where the (departmentId, salary) pair matches the maximum salary for each department.\n\nResult after applying the WHERE clause:\n![image](https://assets.leetcode.com/users/images/d6e17cdf-3abf-4939-8d6b-726a67896c21_1706538655.1041048.png)\n\n*Step 3: SELECT Clause*\nFinally, the SELECT clause specifies the columns to include in the output, with aliases for better readability.\n\nFinal Result:\n![image](https://assets.leetcode.com/users/images/114a0c83-62dc-4102-96e6-b14d216f9610_1706538704.3250432.png)\n\n\n\n\n**Query :**\n```\nSELECT \n    Department.name AS Department,\n    Employee.name AS Employee,\n    Employee.salary AS Salary\nFROM \n    Employee\nINNER JOIN \n    Department ON Employee.departmentId = Department.id\nWHERE \n    (Employee.departmentId, Employee.salary) IN \n    (SELECT \n        departmentId, MAX(salary) \n     FROM \n        Employee \n     WHERE \n        Employee.departmentId = Department.id\n     GROUP BY \n        departmentId)\n\n
['MySQL', 'MS SQL Server']