4
I would like to group the sum of one column per quarter, that is every three months.
I have the following query
which groups from month to month:
select month(data) as mes, year(data) as ano, ifnull(sum(det.quantidade),0) as total
from documento as doc
inner join documento_serie as serie on serie.id = doc.documento_serie_id
inner join documento_detail as det on doc.id = det.documento_id
inner join phos_iva as iva on iva.id = det.iva_id
where serie.documento_categoria_id = 3
group by mes, ano
order by mes, ano desc
How can I group the sum of a column at the intervals of [January, March],[April, June],[July, September],[October, December]?
It should also be months for a single year.
There would be no way to group by
MONTH(data-1)/4
?– Jefferson Quesado