The SQL below brings the number of entries made month by month, until then blz. I needed to show the last 6 months, even if it was zero, but in this select it would only bring up when there are records.
select
extract(month from data_cad) as mes,
count(*) as qtd
from mv_clientes
where (ativo not in('C'))
and (data_cad between '2017-12-01' and '2018-05-31')
group by 1
I'm using MySQL, but I do not know if that's the case, I could see SQL in another database and translate to MySQL
The result of this SQL is
mes qtd
3 | 5
4 | 8
5 | 23
I needed it to be:
mes qtd
12 | 0
1 | 0
2 | 0
3 | 5
4 | 8
5 | 23