Skip to content

Instantly share code, notes, and snippets.

@BrunoDSouza
Last active June 24, 2017 04:54
Show Gist options
  • Save BrunoDSouza/c8389e2312f339d074708cd28b241d78 to your computer and use it in GitHub Desktop.
Save BrunoDSouza/c8389e2312f339d074708cd28b241d78 to your computer and use it in GitHub Desktop.
select m.COD_PRODUTO,
p.DESCRICAO,
sum(m.QTD_ITENS) as Qtd ,
(sum(m.QTD_ITENS) * 100 / (select sum(m2.QTD_ITENS) from movimentacoes as m2)) as Percentual
from movimentacoes as m
join produto as p
on p.idproduto = m.cod_produto
where m.cod_tipomovimento = 1
group by m.COD_PRODUTO, p.descricao
order by Percentual desc
limit 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment