Total de produtos vendidos por mes
Tenho esta sentença que mostra totais reais do mês em um determinado ano.
meu cliente quer que apareça por produto, mesmo que seja item por item.
Total vendido do produto por mês.
Segue link com os campos da tabela:
https://drive.google.com/open?id=0B1WyIh_VqZ3NUXp4WWxBclRwWkU
SELECT
ano1 as ano,
mes1 as mes,
nome_mes1 as nome_mes,
sum (total1) as total
from
(select
extract( year from ITEVENDAS_ECF.DATA) as ano1,
extract(month from ITEVENDAS_ECF.DATA) as mes1,
case extract (month from ITEVENDAS_ECF.DATA)
when 1 then 'Janeiro'
when 2 then 'Fevereiro'
when 3 then 'Março'
when 4 then 'Abril'
when 5 then 'Maio'
when 6 then 'Junho'
when 7 then 'Julho'
when 8 then 'Agosto'
when 9 then 'Setembro'
when 10 then 'Outubro'
when 11 then 'Novembro'
when 12 then 'Dezembro'end as nome_mes1,
SUM(ITEVENDAS_ECF.TOTAL) as total1
from
ITEVENDAS_ECF
where
ITEVENDAS_ECF.CANCELADO = '0' and
extract( year from ITEVENDAS_ECF.DATA) = '2015'
group by
ano1, mes1, nome_mes1, ITEVENDAS_ECF.DESCRICAO
)
group BY
ano, mes, nome_mes
order by
ano, mes
Agradeço desde já se conseguirem me ajudar.
Discussão (6)
Carregando comentários...