Created
April 13, 2016 18:16
-
-
Save cesarAugusto1994/3fb7309ffa48a8d556999fe7d22b7b9c 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) | |
LEFT JOIN webpdv.grupos_usuarios gu ON (gu.id_grupo_usuario = u.id_grupo_usuario) | |
LEFT JOIN webpdv.prestador p ON (p.empno = u.empno) | |
LEFT JOIN webpdv.prestador_tipo pt ON (pt.id = p.prestador_tipo_id) | |
LEFT JOIN webpdv.pessoas pe ON (pe.id_pessoa = p.id_pessoa) | |
INNER JOIN webpdv.empresa_filial ef ON (ef.storeno = u.id_loja) | |
LEFT JOIN webpdv.filial_tipo ft ON (ft.id = ef.filial_tipo_id) | |
WHERE u.ativo = 1 | |
AND pt.id IN (721, 71) 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