IcaroPeretti

Untitled

Mar 17th, 2022 (edited)
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT p.qtdabe ,p.numped,p.codfil FROM e120ped p
  2. INNER JOIN (SELECT SUM(e120ipd.qtdabe) AS TOTAL_ABE,
  3. e120ipd.numped AS PED,
  4. e120ipd.codfil AS FIL,
  5. e120ipd.codemp AS EMP
  6. FROM e120ped ped
  7. INNER JOIN e120ipd
  8. ON e120ipd.codemp = ped.codemp
  9. AND e120ipd.codfil = ped.codfil
  10. AND e120ipd.numped = ped.numped
  11. GROUP BY
  12. e120ipd.codemp,
  13. e120ipd.codfil,
  14. e120ipd.numped
  15. ) AS T ON t.ped = p.numped AND t.fil = p.codfil AND t.emp = p.codemp AND t.total_abe <> p.qtdabe
RAW Paste Data Copied