In that case you should only use a subquery.
select sum(ifnull(ENERO,0)) as ENERO, sum(ifnull(FEBRERO,0)) as FEBRERO -- Los otros meses...
from (
select
(case month(p.fechaVent) when 1 then sum(p.totalVent) end) AS "ENERO",
(case month(p.fechaVent) when 2 then sum(p.totalVent) end) AS "FEBRERO"
-- Los otros meses..
from proformas p
group by month(p.fechaVent)
) as subconsulta;
Explaining:
select
(case month(p.fechaVent) when 1 then sum(p.totalVent) end) AS "ENERO",
(case month(p.fechaVent) when 2 then sum(p.totalVent) end) AS "FEBRERO"
-- Los otros meses..
from proformas p
group by month(p.fechaVent)
The previous code performs the query you propose in the question, returning a table more or less like this.
+-----------+-----------+------+
| ENERO | FEBRERO | ... |
+-----------+-----------+------+
| 100.000 | NULL | ... |
+-----------+-----------+------+
| NULL | 65.000 | ... |
+-----------+-----------+------+
| NULL | NULL | ... |
+-----------+-----------+------+
| NULL | NULL | ... |
+-----------+-----------+------+
| NULL | NULL | ... |
+-----------+-----------+------+
| ... | ... | ... |
+-----------+-----------+------+
Now you have a new table and therefore you can make a query about it, it would only suffice to add the rows of each column, but nevertheless you should consider that:
sum(ENERO) -- El resultado será NULL
-- puesto que 100.000 + NULL + ... + NULL = NULL
Then you should only convert to zero (0) everything that is null
sum(ifnull(ENERO,0)) -- Siempre se completa primero la función interna
-- Ahora 100.000 + (0) + ... + (0) = 100.000
Then considering the above
select sum(ifnull(ENERO,0)) as ENERO, sum(ifnull(FEBRERO,0)) as FEBRERO -- Los otros meses...
from (...) -- Donde (...) es la tabla resultado de la consulta que describimos arriba
You will see that the table that we described above "does not really exist", since it is a query, now the result of a query is a table so it can be consulted about it, therefore the only thing that is subtracting is giving it a name alias
to that query only as for fulfilling good practices.
select sum(ifnull(ENERO,0)) as ENERO, sum(ifnull(FEBRERO,0)) as FEBRERO -- Los otros meses...
from (...) as subconsulta;
I hope it's a bit illustrative for you, here you can find more information link .