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