Кажется, вы хотите условную агрегацию. Я бы порекомендовал поместить данные в строки и повернуть их в приложении:
select department, is_permenanent, gender,
floor(months_between(dob, sysdate) / 12) as age,
sum(annual_bonus),
sum(monthly_bonus)
sum(quarterly_bonus)
from employee
group by department, is_permenanent, gender,
floor(months_between(dob, sysdate) / 12);
Вы можете повернуть данные в SQL, используя условное агрегирование:
select floor(months_between(dob, sysdate) / 12) as age,
sum(case when department = 'Sales' and
is_permanent = 'Yes' and
gender = 'F'
then annual_bonus else 0
end) as sales_perm_f_annual,
sum(case when department = 'Sales' and
is_permanent = 'Yes' and
gender = 'F'
then annual_monthly else 0
end) as sales_perm_f_monthly,
sum(case when department = 'Sales' and
is_permanent = 'Yes' and
gender = 'F'
then quarterly_bonus else 0
end) as sales_perm_f_quarterly_bonus,
. . .
from employee
group by floor(months_between(dob, sysdate) / 12);