RESULTADO INVALIDO
06/12/2021
0
SELECT
/*SAIDA*/
GELANSAI.ITEM ITEM_SAIDA,
GECADSAI.DATA DATA_SAIDA,
GELANSAI.QTDE QTDE_SAIDA,
GELANSAI.VLRMED VLRMED_SAIDA,
GECADSAI.CDC CDC_SAIDA,
/*ITENS*/
I.NOME,
I.UNI_CON,
I.CUSTO VLR_UNI,
(SELECT FIRST 1 GEGRUPOS.NOME FROM GEGRUPOS WHERE GEGRUPOS.COD = I.GRU) GRUPO,
(SELECT FIRST 1 NOME FROM TBCENCUS WHERE COD=GECADSAI.CDC) CDC,
/*DEVOLUCAO*/
GELANDEV.ITEM ITEM_DEV,
GECADDEV.DATA DATA_DEV,
GELANDEV.QTDE QTDE_DEV,
GELANDEV.VLRMED VLRMED_DEV,
GECADDEV.CDC CDC_DEV
FROM GECADSAI
LEFT JOIN GELANSAI ON GECADSAI.ANO=GELANSAI.ANO
AND GECADSAI.MES=GELANSAI.MES
AND GECADSAI.DOC=GELANSAI.DOC
LEFT JOIN GEITENS I ON GELANSAI.ITEM=I.COD
LEFT JOIN TBCENCUS T ON T.COD=GECADSAI.CDC
LEFT JOIN GELANDEV ON GELANDEV.id_gelansai=GELANSAI.id_gelansai
LEFT JOIN GECADDEV ON GECADDEV.ID=GELANDEV.ID_GECADDEV
WHERE GECADSAI.ANO=:ANO
AND GECADSAI.MES=:MES
AND GECADSAI.CDC BETWEEN :CDC1 AND :CDC2
AND GELANSAI.CONSOL='T'
AND GECADSAI.CONSOL='T'
AND GECADSAI.DATA BETWEEN :DATA1 AND :DATA2
ORDER BY CDC_SAIDA, NOME
Marcos Batista
Post mais votado
06/12/2021
WHERE GECADSAI.ANO=:ANO
AND GECADSAI.MES=:MES
AND GECADSAI.CDC BETWEEN :CDC1 AND :CDC2
AND (COALESCE(GELANSAI.CONSOL,'')='T' OR COALESCE(GECADSAI.CONSOL,'')='T')
AND GECADSAI.DATA BETWEEN :DATA1 AND :DATA2
ORDER BY CDC_SAIDA, NOME
Emerson Nascimento
Mais Posts
07/12/2021
Marcos Batista
WHERE GECADSAI.ANO=:ANO
AND GECADSAI.MES=:MES
AND GECADSAI.CDC BETWEEN :CDC1 AND :CDC2
AND (COALESCE(GELANSAI.CONSOL,'')='T' OR COALESCE(GECADSAI.CONSOL,'')='T')
AND GECADSAI.DATA BETWEEN :DATA1 AND :DATA2
ORDER BY CDC_SAIDA, NOME
SERÁ QUE CONSIGO FAZER ISSO COM O BETWEEN DATA TBM ?
SELECT
/*SAIDA*/
GELANSAI.ITEM ITEM_SAIDA,
GECADSAI.DATA DATA_SAIDA,
GELANSAI.QTDE QTDE_SAIDA,
GELANSAI.VLRMED VLRMED_SAIDA,
GECADSAI.CDC CDC_COD,
/*ITENS*/
I.NOME,
I.UNI_CON,
I.CUSTO VLR_UNI,
(SELECT FIRST 1 GEGRUPOS.NOME FROM GEGRUPOS WHERE GEGRUPOS.COD = I.GRU) GRUPO,
(SELECT FIRST 1 NOME FROM TBCENCUS WHERE COD=GECADSAI.CDC) CDC,
/*DEVOLUCAO*/
GELANDEV.ITEM ITEM_DEV,
GECADDEV.DATA DATA_DEV,
GELANDEV.QTDE QTDE_DEV,
GELANDEV.VLRMED VLRMED_DEV,
GECADDEV.CDC CDC_COD
FROM GECADSAI
LEFT JOIN GELANSAI ON GECADSAI.ANO=GELANSAI.ANO
AND GECADSAI.MES=GELANSAI.MES
AND GECADSAI.DOC=GELANSAI.DOC
LEFT JOIN GEITENS I ON GELANSAI.ITEM=I.COD
LEFT JOIN TBCENCUS T ON T.COD=GECADSAI.CDC
LEFT JOIN GELANDEV ON GELANDEV.id_gelansai=GELANSAI.id_gelansai
LEFT JOIN GECADDEV ON GECADDEV.ID=GELANDEV.ID_GECADDEV
WHERE GECADSAI.ANO=:ANO
AND GECADSAI.MES=:MES
AND GECADSAI.CDC BETWEEN :CDC1 AND :CDC2
AND GECADSAI.DATA BETWEEN :DATA1 AND :DATA2
AND GECADDEV.DATA BETWEEN :DATA1 AND :DATA2
AND (COALESCE(GELANSAI.CONSOL,'')='T' OR COALESCE(GECADSAI.CONSOL,'')='T')
ORDER BY CDC, NOME
09/12/2021
Marcos Batista
basta seguir a mesma lógica.
Segui a mesma lógica, mas não me trouxe resultado, poderia me mostra como ficaria por gentileza ...
09/12/2021
Emerson Nascimento
AND ( (NOT GECADSAI.DATA IS NULL AND GECADSAI.DATA BETWEEN :DATA1 AND :DATA2) OR (NOT GECADDEV.DATA IS NULL AND GECADDEV.DATA BETWEEN :DATA1 AND :DATA2) )
sempre publique o que você já testou, pra evitar de receber uma resposta que você já testou.
Clique aqui para fazer login e interagir na Comunidade :)