text: SELECT A.DTPAGTO AS PAGTO_DUPLIC,
         A.RECNUM,
         H.NUMTRANSENT,
         H.NUMTRANSVENDA,
         NVL(D.NUMTRANSENTDEVFORNEC, '0') AS NUMTRANSENTDEVFOR,
         B.CODFORNEC,
         B.FORNECEDOR,
         B.CGC,
         E.NUMNOTA AS NOTA_DEV,
         E.DTSAIDA,
         E.VLTOTAL AS VL_NOTA_DEV,
         E.CODFILIAL AS CODFILIAL_DEV,
         E.OBS,
         E.NFFORNEC AS NUM_NOTA_COMPRA,
         A.CODCONTA,
         C.CONTA,
         A.CODFILIAL AS FILIAL_PAGTO,
         A.HISTORICO,
         A.NUMNOTA AS NOTA_VENDA,
         A.DUPLIC,
         A.VALOR,
         A.VALORDEV,
         A.VPAGOBORDERO,
         A.RECNUM,
         A.RECNUMBAIXA,
         A.CODROTINABAIXA,
         G.RAZAOSOCIAL,
         G.CGC
    FROM PCLANC      A,
         PCFORNEC    B,
         PCCONTA     C,
         PCMOVCRFOR  D,
         PCNFSAID    E,
         PCFILIAL    G,
         PCDEVFORNEC H
   WHERE H.NUMTRANSENT = A.NUMTRANSENT
     AND H.NUMNOTADEV = E.NUMNOTA
     AND D.NUMTRANSENTDEVFORNEC(+) = H.NUMTRANSVENDA
     AND A.CODFORNEC = B.CODFORNEC
     AND A.CODCONTA = C.CODCONTA
     AND G.CODIGO = A.CODFILIAL
     AND H.NUMTRANSENT <> 0
     AND A.VALORDEV IS NOT NULL
     AND A.VALORDEV <> 0
     AND D.NUMTRANSENTDEVFORNEC IS NULL
     AND A.DTPAGTO BETWEEN '01-JAN-2017' AND '30-APR-2017'
   ORDER BY B.FORNECEDOR, A.CODFILIAL, A.DTPAGTO