Created
April 14, 2016 14:44
-
-
Save cesarAugusto1994/e89c3ed9dc78ae3a82e47d31b62580c5 to your computer and use it in GitHub Desktop.
Informações de Lojas e Usuarios para 2Tech
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', | |
IF(ef.empresa_id = 1, pt.nome_tipo, ft.nome) AS 'Grupo Comissão', | |
IF(pe.id_tipo_pessoa = 'F', 'PF', 'PJ') AS Categoria | |
FROM webpdv.usuarios u | |
INNER JOIN webpdv.usuario_cargo uc ON (uc.id_usuario = u.id_usuario) | |
INNER JOIN webpdv.cargo c ON (c.id_cargo = uc.id_cargo) | |
INNER JOIN sqldados.store s ON (s.no = u.id_loja) | |
INNER JOIN webpdv.grupos_usuarios gu ON (gu.id_grupo_usuario = u.id_grupo_usuario) | |
INNER JOIN webpdv.prestador p ON (p.empno = u.empno) | |
INNER JOIN webpdv.prestador_tipo pt ON (pt.id = p.prestador_tipo_id) | |
INNER JOIN webpdv.pessoas pe ON (pe.id_pessoa = p.id_pessoa) | |
INNER JOIN webpdv.empresa_filial ef ON (ef.storeno = u.id_loja) | |
INNER JOIN webpdv.filial_tipo ft ON (ft.id = ef.filial_tipo_id) | |
WHERE u.ativo = 1 | |
AND u.id_loja = 1009 | |
AND (pt.id IN (71, 721) OR ft.id IN (11, 21)) | |
GROUP BY u.id_usuario | |
ORDER BY s.no ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment