Created
April 12, 2017 17:17
-
-
Save felipefinhane/8df87e791389047f0d5ecc97363aaf73 to your computer and use it in GitHub Desktop.
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 | |
nfe.id_nfe, | |
nfe.dt_emissao, | |
nfe.numero | |
FROM | |
fis_nfe nfe | |
LEFT JOIN | |
com_projeto_parametros_venda propv ON propv.id_projeto_parametros_venda = nfe.id_projeto_parametros_venda | |
AND propv.stat != 0 | |
LEFT JOIN | |
com_projeto pro ON pro.id_projeto = propv.id_projeto | |
AND pro.stat != 0 | |
INNER JOIN | |
CorporationMainData emp ON emp.id_empresa = nfe.id_empresa | |
AND emp.stat != 0 | |
INNER JOIN | |
PartnerMainData par ON par.id_parceiro = nfe.id_parceiro | |
AND par.stat != 0 | |
LEFT JOIN | |
PartnerPf ppf ON ppf.id_parceiro = par.id_parceiro | |
AND ppf.stat != 0 | |
LEFT JOIN | |
PartnerPj ppj ON ppj.id_parceiro = par.id_parceiro | |
AND ppj.stat != 0 | |
INNER JOIN | |
fis_nfe_status sta ON sta.id_nfe_status = nfe.id_nfe_status | |
AND sta.stat != 0 | |
INNER JOIN | |
fis_nfe_ambiente na ON na.id_nfe_ambiente = nfe.id_nfe_ambiente | |
AND na.stat != 0 | |
LEFT JOIN | |
fis_nfe_itens i ON nfe.id_nfe = i.id_nfe AND i.stat != 0 | |
WHERE | |
nfe.stat <> 0 AND nfe.id_empresa = 29 | |
AND nfe.id_nfe_ambiente = 1 | |
AND pro.id_projeto = '198' | |
AND nfe.dt_emissao BETWEEN '2017-04-11 00:00:00' AND '2017-04-11 23:59:59' | |
AND nfe.id_nfe_status = '1' | |
GROUP BY nfe.id_nfe | |
ORDER BY nfe.numero DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment