Calculations over UNION, merge query repetitive code I am struggling with this query a lot mainly because of the repetition which possibly could be reduced - hopefully.

The general idea is to display sums of each table for a given month and display it as a pivot table.

Current code is in my opinion very messy and repetitive but the main thing is it doesn't allow me to make the calculations, due the UNION joining.

For each month as following ( I assume this has to be a derivative table that takes values of the other and calculates this formula for each month ): 

Calculation Formula = (
    employees_salaries + 
    employees_salaries_insurence_costs +
    employees_agreement +
    employees_agreement_insurence_cost + 
    employees_extras +
    employees_to_hand +
    employees_delegations ) - employees_deductions


Current query is working displays everything properly but the questions and desired output :


Question : Is there any possible query minification
         - Possible query structure to enable the calculation formula


Desired output : Current layout is what needs to stay

I am trying since few days but I am unable to accomplish my desired result, any tips will be really helpful.

Output

+------------------------------------+---------------------+------+-------+-------+-----+------+-------+----------+-----------+---------+----------+----------+
|         employees_salaries         |       January       | Febr | March | April | May | June | July  |  August  | September | October | November | December |
+------------------------------------+---------------------+------+-------+-------+-----+------+-------+----------+-----------+---------+----------+----------+
| employees_salaries                 | 0                   |    0 |     0 |     0 |   0 |    0 |     0 | 15826.12 |         0 |       0 |        0 |        0 |
| Calculations                       | Calculation Formula |      |       |       |     |      |       |          |           |         |          |          |
| employees_salaries_insurence_costs | 0                   |    0 |     0 |     0 |   0 |    0 |     0 |  5044.44 |         0 |       0 |        0 |        0 |
| employees_agreement                | 0                   |    0 |     0 |     0 |   0 |    0 |   250 |        0 |         0 |       0 |        0 |     3550 |
| employees_agreement_insurence_cost | 0                   |    0 |     0 |     0 |   0 |    0 | 71.05 |        0 |         0 |       0 |        0 |   178.65 |
| employees_extras                   | 0                   |    0 |     0 |     0 |   0 |    0 |     0 |        0 |         0 |    1.00 |        0 |        0 |
| employees_deductions               | 0                   |    0 |     0 |     0 |   0 |    0 |     0 |    45.60 |         0 |    1.00 |        0 |        0 |
| employees_to_hand                  | 0                   |    0 |     0 |     0 |   0 |    0 |     0 |        0 |         0 |  111.00 |   555.00 |        0 |
| employees_delegations              | 0                   |    0 |     0 |     0 |   0 |    0 |     0 |        0 |      2520 |     540 |        0 |        0 |
+------------------------------------+---------------------+------+-------+-------+-----+------+-------+----------+-----------+---------+----------+----------+


MCVE Example + Schema : https://www.db-fiddle.com/f/8RvfD3uA4cSSVgmhoP2co6/9
Setting aside the odd ball row (Calculations/Calculation Formula) for the moment, I opted for doing a union all of the raw data (in a derived table), and then grouped/pivoted the derived table, eg:

select ctype                                                       As employees_salaries,
       COALESCE(SUM(case when month(cdate)=1  then camount end),0) As January, 
       COALESCE(SUM(case when month(cdate)=2  then camount end),0) As Febr, 
       COALESCE(SUM(case when month(cdate)=3  then camount end),0) As March, 
       ...
from   (select 'employees_salaries'                  as ctype,
               mmonth                                as cdate,
               gross                                 as camount
        from   employees_salaries
        where  year(mmonth) = year(curdate())

        union all

        select 'employees_salaries_insurence_costs',
               mmonth,
               insurence_cost1+insurence_cost2
        from   employees_salaries
        where  year(mmonth) = year(curdate())

        union all
        ... ) as c
group by ctype, year(cdate)

order by 1


Here's a fiddle for the complete query.