Sorry,

I should try group by department before group by to_char(transdate,'YYYY'), to_char(transdate,'Q');