text: WITH COMPRABASE_MENOR AS
   (SELECT M.DTMOV, M.CODPROD, M.DESCRICAO, M.PUNIT, M.QT, M.NUMNOTA
      FROM PCMOV M, PCFORNEC F
     WHERE F.CODFORNEC = M.CODFORNEC
       AND F.CODFORNECPRINC = 2
       AND M.CODOPER = 'E'
       AND M.DTMOV BETWEEN '01-JAN-2018' AND '31-DEC-2019'
       AND M.DTCANCEL IS NULL),
  COMPRABASE_MAIOR AS
   (SELECT M.DTMOV, M.CODPROD, M.DESCRICAO, M.PUNIT, M.QT, M.NUMNOTA
      FROM PCMOV M, PCFORNEC F
     WHERE F.CODFORNEC = M.CODFORNEC
       AND F.CODFORNECPRINC = 2
       AND M.CODOPER = 'E'
       AND M.DTMOV BETWEEN '01-JAN-2018' AND '31-DEC-2019'
       AND M.DTCANCEL IS NULL)
  SELECT P.DTMOV,
         G.CODPROD,
         G.DESCRICAO,
         P.NUMNOTA,
         P.QT,
         G.PUNIT     PUNIT_G,
         P.PUNIT     PUNIT_P
    FROM COMPRABASE_MENOR P
   INNER JOIN COMPRABASE_MAIOR G
      ON P.CODPROD = G.CODPROD
   GROUP BY P.DTMOV, G.CODPROD, G.DESCRICAO, P.NUMNOTA, P.QT, G.PUNIT, P.PUNIT
  HAVING (MAX(G.PUNIT) / MIN(P.PUNIT)) > 1.10 AND MAX (P.DTMOV) >= '01-JAN-2019'
  ORDER BY G.CODPROD;/