Easy Way To Resolve
\n\n# Approach\n Describe your approach to solving the problem. \nCreated a temporary table first and got the Unique department_id and salaey, Then did a join w
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nCreated a temporary table first and got the Unique department_id and salaey, Then did a join with two tables, used the temp table in the where condition.\n\n\n# Code\n```postgresql []\n-- Write your PostgreSQL query statement below\nWITH temp as (SELECT e.departmentId  as "department_id",MAX(e.salary) as "salary" FROM Employee e  GROUP BY 1)\n\nSELECT  d.name as "Department",e.name as "Employee",e.salary as "Salary" FROM Employee \ne LEFT JOIN Department d ON e.departmentId = d.id\nWHERE (d.id,e.salary)  IN (SELECT department_id, salary  FROM temp)\n```
['PostgreSQL']