; with pt as (select year(payment_date) income_year,
name staff,
sum(amount) total_paiments
from payment P
join staff_list SL on P.staff_id=SL.id
group by income_year, staff with rollup)
select income_year,
case when staff is null and income_year is not null then 'Year total'
when staff is null and income_year is null then 'Total'
else staff end staff,
total_paiments
from pt