Good day, I have a postgresql query but I need to modify its structure from columns to rows:
select anno, SUM(total_sales) as sumas, sexo_
from sivigila_a
where cod_event = 110
GROUP BY anno, sexo_
ORDER BY 1
the result is the following:
and I need to convert it to this but with the totals of the previous sum
The problem is that the information does not appear and I really do not understand how to perform the corosstab
SELECT * FROM crosstab(
'select anno, SUM(total_sales) as sumas, sexo_
from sivigila_a
where cod_event = 110
GROUP BY anno, sexo_
ORDER BY 1',$$VALUES ('F'::text), ('M'::text)$$
)AS x (anno text, "F" text, "M" text);
I hope it can be solved. Thanks