A little analytic can isolate the salaries we want
SQL> select first_name,
2 department_id,
3 case when row_number() over ( partition by first_name order by hire_date ) = 1 then salary end first_sal_only
4 from hr.employees;
FIRST_NAME DEPARTMENT_ID FIRST_SAL_ONLY
-------------------- ------------- --------------
Adam 50 8200
Alana 50 3100
Alberto 80 12000
Alexander 30 3100
Alexander 60
Alexis 50 4100
Allan 80 9000
Alyssa 80 8800
Amit 80 6200
Anthony 50 3000
Britney 50 3900
...
Vance 50 2800
William 110 8300
William 80
Winston 50 3200
107 rows selected.
From there, we just go back to our normal group by
SQL> select department_id,
2 sum(first_sal_only)
3 from
4 (
5 select first_name,
6 department_id,
7 case when row_number() over ( partition by first_name order by hire_date ) = 1 then salary end first_sal_only
8 from hr.employees
9 )
10 group by department_id
11 order by 1;
DEPARTMENT_ID SUM(FIRST_SAL_ONLY)
------------- -------------------
10 4400
20 19000
30 22400
40 6500
50 128400
60 15000
70 10000
80 281300
90 58000
100 43408
110 20308
7000
12 rows selected.
SQL>