Вы можете использовать функцию FIRST :
SELECT dept_name, SUM(salary), MAX(salary), MIN(salary),
MAX(emp_name) KEEP (DENSE_RANK FIRST ORDER BY salary) AS Min_salary_emp,
MAX(emp_name) KEEP (DENSE_RANK LAST ORDER BY salary) as Max_salary_emp
FROM emp
GROUP BY dept_name;
Обратите внимание: если у вас более одного сотрудника с одинаковой зарплатой, вы получаете только одного из них.
В зависимости от ваших требований вы также можете использовать Pattern Matching
SELECT dept_name, MAX_salary, MIN_salary, salary, emp_name,
Min_salary_emp, Max_salary_emp
FROM emp
MATCH_RECOGNIZE (
PARTITION BY dept_name
ORDER BY salary
MEASURES
FINAL MIN(salary) AS MIN_salary,
FINAL MAX(salary) AS MAX_salary,
a.emp_name AS Min_salary_emp,
c.emp_name AS Max_salary_emp
ALL ROWS PER MATCH
PATTERN ( (a+ {- b* -} c+) | a )
DEFINE
a AS salary = MIN(salary),
c AS salary = MAX(salary)
);