Use window functions:
SELECT DISTINCT Dept_id,
MIN(Salary) OVER (PARTITION BY Dept_id) Min_Salary,
FIRST_VALUE(Emp_Name) OVER (PARTITION BY Dept_id ORDER BY Salary) Min_salary_emp_name,
MAX(Salary) OVER (PARTITION BY Dept_id) Max_Salary,
FIRST_VALUE(Emp_Name) OVER (PARTITION BY Dept_id ORDER BY Salary DESC) Max_salary_emp_name
FROM tablename;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.