Last active
February 23, 2016 13:00
-
-
Save cesarAugusto1994/791a6f328542a9f22e98 to your computer and use it in GitHub Desktop.
Transferências SegTec para as Lojas
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 | |
nfce.nfno_nfname AS NF, | |
rm.storeno AS Loja, | |
TRIM(rmp.prdno) AS Produto, | |
prod.name AS 'Nome Produto', | |
ROUND(rmp.qtty_fiscal / 1000) AS Quantidade, | |
REPLACE(ROUND(prp.cost / 10000, 2), '.', ',') AS 'Valor Custo', | |
REPLACE(ROUND(rmp.valor_unitario / 100, 2), '.', ',') AS 'Valor Venda', | |
REPLACE(ROUND(rmp.qtty_fiscal / 1000 * prp.cost / 10000, 2), '.', ',') AS 'Valor Custo Total', | |
REPLACE(ROUND(rmp.qtty_fiscal / 1000 * rmp.valor_unitario / 100, 2), '.', ',') AS 'Valor Total Venda' | |
FROM webpdv.remessa_movimentacao rm | |
INNER JOIN webpdv.remessa_movimentacao_produto rmp ON (rmp.id_remessa_movimentacao = rm.id_remessa_movimentacao) | |
INNER JOIN webpdv.remessa_situacao rs ON (rs.id_remessa_situacao = rm.id_remessa_situacao) | |
LEFT JOIN webpdv.produto prod ON (prod.prdno = rmp.prdno) | |
LEFT JOIN webpdv.nf_controle_eletronico nfce ON (nfce.id_remessa_movimentacao = rm.id_remessa_movimentacao) | |
LEFT JOIN sqldados.prp prp ON (prp.storeno = rmp.storeno AND prp.prdno = rmp.prdno) | |
WHERE rs.id_remessa_situacao IN (42, 51, 161, 281, 321, 341, 381) | |
AND prod.typeno = 91 | |
GROUP BY rm.id_remessa_movimentacao, rmp.id_remessa_movimentacao_produto | |
ORDER BY rmp.storeno; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment