Last active
May 2, 2016 18:42
-
-
Save cesarAugusto1994/bd0ee787fddba2d8ab61ba3677c7272f to your computer and use it in GitHub Desktop.
Busca de Quantidade de Vendas de Fácil Aprender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
xa.storeno AS Loja, | |
date_format(xa.date, '%m/%Y') AS Mes, | |
CONCAT(xa.empno, ' - ', pre.nome) AS Vendedor, | |
pre.cpf_cnpj AS CPF, | |
ROUND(SUM(qtty / 1000)) AS Quantidade, | |
REPLACE(ROUND(sum(price / 100 * xa.qtty / 1000), 2), '.', ',') AS 'Valor Total' | |
FROM sqldados.xalog2 xa | |
INNER JOIN sqlpdv.pxa pxa ON (pxa.storeno = xa.storeno AND pxa.pdvno = xa.pdvno AND pxa.xano = xa.xano) | |
INNER JOIN sqldados.eord eo ON (eo.storeno = pxa.storeno AND eo.pdvno = pxa.pdvno AND eo.ordno = pxa.eordno) | |
LEFT JOIN webpdv.prestador pre ON (pre.empno = xa.empno) | |
WHERE xa.prdno = ' 4895002' | |
AND xa.qtty > 0 | |
AND xa.date BETWEEN '20160401' AND '20160430' | |
AND eo.status = 3 | |
GROUP BY date_format(date, '%m/%Y'), xa.empno | |
ORDER BY Mes, Quantidade DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment