Tengo la sgte. sentencia:
Código:
Esto muestra:SELECT ol.MaeCod, SUM(ol.OrdCant) as OrdCant, SUM(ol.OrdCaEnt) as OrdCaEnt FROM RORDCAB oc, RORDLIN ol, RMAEBOD b WHERE oc.CiaCod = ol.CiaCod AND oc.OrdId = ol.OrdId AND oc.OrdSec = ol.OrdSec AND ol.CiaCod = b.CiaCod AND ol.MaeCod = b.MaeCod AND oc.OrdEst = 'A' AND oc.OrdSF = 'N' AND b.BdgId = 1 GROUP BY ol.MaeCod ORDER BY ol.MaeCod //go SELECT oc.OrdId, ol.MaeCod, ol.OrdCant, ol.OrdCaEnt FROM RORDCAB oc, RORDLIN ol, RMAEBOD b WHERE oc.CiaCod = ol.CiaCod AND oc.OrdId = ol.OrdId AND oc.OrdSec = ol.OrdSec AND ol.CiaCod = b.CiaCod AND ol.MaeCod = b.MaeCod AND oc.OrdEst = 'A' AND oc.OrdSF = 'N' AND b.BdgId = 1 //go SELECT * FROM RMAEBOD WHERE MaeCod = '7174165J0038B' AND BdgId = 1
En la consulta de arriba, debe aparecerme el 4 si la resta de OrdCant - OrdCaEnt es diferente de MaePed.
Espero que se entienda.
Cualquier ayuda, consejo, etc. es bienvenido.
Gracias!