Change the column header with formula

1

I searched for infinite on the internet and did not find it, I hope someone can help me, I have the following table:

The numbers -1, -2, -3 ... represent the months, that is, last month (-1), delayed (-2) ... and so on, what I need is some formula to inform the month instead of these numbers in this table. The command to get into this table is as follows:

SELECT 
(SELECT SUM(quantidade) AS Quantidade
FROM genius.itens_compra
LEFT JOIN genius.compras ON genius.compras.Id = Id_compra
WHERE 'Id_produto' = 489 AND EXTRACT(YEAR_MONTH FROM 'data_compra') BETWEEN EXTRACT(YEAR_MONTH FROM CURDATE() - INTERVAL 10 MONTH) AND EXTRACT(YEAR_MONTH FROM CURDATE() - INTERVAL 10 MONTH)
)AS '-10';

This is repeated from -10 to -1, I just need to change the 'AS-10' part on the last line by some command that gives me a date

    
asked by anonymous 26.08.2016 / 00:16

0 answers