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 | |
UPPER(u.nome_usuario) AS usuario, | |
pe.cpf_cnpj AS CPF, | |
s.state AS Estado, | |
s.city AS Cidade, | |
s.nei AS Bairro, | |
u.login AS Login, | |
concat(u.login, '@2tech') AS Senha, | |
concat(u.id_loja, '-', s.city) AS Filial, | |
concat(u.id_loja, '-', s.city) AS 'Grupo Vendedor', |
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 | |
UPPER(u.nome_usuario) AS usuario, | |
pe.cpf_cnpj AS CPF, | |
s.state AS Estado, | |
s.city AS Cidade, | |
s.nei AS Bairro, | |
u.login AS Login, | |
concat(u.login, '@2tech') AS Senha, | |
concat(u.id_loja, '-', s.city) AS Filial, | |
concat(u.id_loja, '-', s.city) AS 'Grupo Vendedor', |
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, | |
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) |
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
CREATE TABLE webpdv.taxa_juros_cartao ( | |
id INT PRIMARY KEY AUTO_INCREMENT, | |
cardno SMALLINT(6), | |
parcela TINYINT(4), | |
acrescimo DECIMAL(10,8), | |
cet DECIMAL(10,8), | |
taxa_mes DECIMAL(13,10), | |
taxa_ano DECIMAL(13,10) | |
); |
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 | |
pxa2.storeno As Loja, pxa2.eordno AS Pedido, DATE_FORMAT(pxa2.date, '%d/%m/%Y') AS 'Data Compra', | |
id_pessoa as 'Cod. Cliente', nome_pessoa as Cliente, REPLACE(ROUND(pxa2.amt/100, 2), '.', ',') as Valor | |
FROM ( | |
SELECT * | |
FROM webpdv.pessoas pe | |
WHERE data_cadastro BETWEEN '2015-01-01 00:00:00' AND '2016-03-18 23:59:59' | |
AND EXISTS(SELECT 'X' | |
FROM sqlpdv.pxa | |
WHERE pxa.custno = pe.id_pessoa |
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 pc.id_pedido_compra, pc.storeno, | |
pc.ordno, pc.vendno, pc.data_faturamento, | |
pc.data_pedido ,pc.data_entrega , pc.amt, pc.icms, pc.icms_reduzido, | |
pc.id_situacao_pedido_compra, pc.id_usuario, pc.id_status, | |
spc.titulo, spc.descricao, u.nome_usuario, vend.name AS nome_fornecedor, | |
( SELECT | |
SUM( | |
(ROUND(pcp.quantidade - pcp.quantidadeRecebida) * (pcp.valorUnitario)) + | |
(ROUND(pcp.quantidade - pcp.quantidadeRecebida) * (vIPI / quantidade)) + | |
(ROUND(pcp.quantidade - pcp.quantidadeRecebida) * (pcp.seguro / quantidade)) + |
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 storeno AS Loja, id_pessoa AS 'Codigo Cliente', cliente AS Cliente, | |
email AS Email, IF(isnull(ddd), '', IF(ddd = 0, '', ddd)) AS DDD, IF(isnull(telefone), '', telefone) AS Telefone, | |
( | |
SELECT REPLACE(ROUND(SUM(xa2.price / 100 * (abs(xa2.qtty) / 1000)), 2), '.', ',') | |
FROM sqlpdv.pxa pxa | |
INNER JOIN sqldados.xalog2 xa2 ON (xa2.storeno = pxa.storeno AND xa2.pdvno = pxa.pdvno AND xa2.xano = pxa.xano) | |
WHERE xa2.custno = id_pessoa | |
AND xa2.xano = transacaoUltimaCompra | |
AND xa2.qtty > 0 | |
) AS 'Ultima Compra', acumulado AS Acumulado |
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 storeno AS Loja, id_pessoa AS 'Codigo Cliente', cliente AS Cliente, | |
email AS Email, ddd AS DDD, telefone AS Telefone, pdvno, transacaoUltimaCompra, | |
( | |
SELECT REPLACE(ROUND(SUM(xa2.price / 100 * xa2.qtty / 1000), 2), '.', ',') | |
FROM sqlpdv.pxa pxa | |
INNER JOIN sqldados.xalog2 xa2 ON (xa2.storeno = pxa.storeno AND xa2.pdvno = pxa.pdvno AND xa2.xano = pxa.xano) | |
WHERE xa2.storeno = t2.storeno AND xa2.pdvno = t2.pdvno AND xa2.xano = transacaoUltimaCompra | |
) AS 'Ultima Compra',acumulado AS Acumulado | |
FROM ( |
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 | |
storeno AS Loja, | |
cliente AS Cliente, | |
email AS Email, | |
ddd AS DDD, | |
telefone AS Telefone, | |
SUM(valorUltimaCompra) AS 'Ultima Compra', | |
SUM(acumulado) AS 'Acumulado' | |
FROM ( | |
SELECT |
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' |