SELECT MONTH(pag_fecha) AS Mes, SUM(pag_importe) AS Ingresos
FROM PAGO
GROUP BY MONTH(pag_fecha) WITH ROLLUP
I would like instead of NULL to get me "Total income"
I already tried it with a CASE but I want to know if there was a simpler way to do it since in the CASE I have to put all the months so that it shows me the result I want
SELECT CASE MONTH(pag_fecha)
WHEN 1 THEN '1'
WHEN 2 THEN '2'
WHEN 3 THEN '3'
WHEN 4 THEN '4'
WHEN 5 THEN '5'
WHEN 6 THEN '6'
WHEN 7 THEN '7'
WHEN 8 THEN '8'
WHEN 9 THEN '9'
WHEN 10 THEN '10'
WHEN 11 THEN '11'
WHEN 12 THEN '12'
ELSE 'Total General'
END AS Mes,
SUM(pag_importe) AS Ingresos
FROM PAGO
GROUP BY MONTH(pag_fecha) WITH ROLLUP