Created
April 11, 2018 01:38
-
-
Save elvisgs/f2e5204f92ed615f17ac50155ee349f8 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 distinct prod.* | |
FROM est_nf_ent nfe | |
JOIN est_nf_ent_it it ON nfe.CD_EMP = it.CD_EMP AND nfe.CD_FILIAL = it.CD_FILIAL and nfe.CD_NF = it.CD_NF | |
JOIN est_prod prod ON it.CD_EMP = prod.CD_EMP AND it.CD_PROD = prod.CD_PROD | |
WHERE nfe.DT_ENT BETWEEN '${data_inicial}' AND '${data_final}' | |
UNION | |
SELECT distinct prod.* | |
FROM est_nf_sai nfs | |
JOIN est_nf_sai_it it ON nfs.CD_EMP = it.CD_EMP AND nfs.CD_FILIAL = it.CD_FILIAL and nfs.CD_NF = it.CD_NF | |
JOIN est_prod prod ON it.CD_EMP = prod.CD_EMP AND it.CD_PROD = prod.CD_PROD | |
WHERE nfs.DT_EMI_NF BETWEEN '${data_inicial}' AND '${data_final}' | |
SELECT distinct cd_barra.* | |
FROM est_nf_ent nfe | |
JOIN est_nf_ent_it it ON nfe.CD_EMP = it.CD_EMP AND nfe.CD_FILIAL = it.CD_FILIAL and nfe.CD_NF = it.CD_NF | |
JOIN est_prod prod ON it.CD_EMP = prod.CD_EMP AND it.CD_PROD = prod.CD_PROD | |
JOIN est_prod_cd_barra cd_barra ON prod.CD_EMP = cd_barra.CD_EMP AND prod.CD_PROD = cd_barra.CD_PROD | |
WHERE nfe.DT_ENT BETWEEN '${data_inicial}' AND '${data_final}' | |
UNION | |
SELECT distinct cd_barra.* | |
FROM est_nf_sai nfs | |
JOIN est_nf_sai_it it ON nfs.CD_EMP = it.CD_EMP AND nfs.CD_FILIAL = it.CD_FILIAL and nfs.CD_NF = it.CD_NF | |
JOIN est_prod prod ON it.CD_EMP = prod.CD_EMP AND it.CD_PROD = prod.CD_PROD | |
JOIN est_prod_cd_barra cd_barra ON prod.CD_EMP = cd_barra.CD_EMP AND prod.CD_PROD = cd_barra.CD_PROD | |
WHERE nfs.DT_EMI_NF BETWEEN '${data_inicial}' AND '${data_final}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment