08/12/2006, 09:33
|
| | | Fecha de Ingreso: noviembre-2006
Mensajes: 381
Antigüedad: 18 años, 1 mes Puntos: 6 | |
Re: Mostrar un campo de otra consulta Nobody's perfect!
Código:
SELECT
ol.MaeCod, SUM(ol.OrdCant) as OrdCant, SUM(ol.OrdCaEnt) as OrdCaEnt, B.MAEPED AS RESULTADO
FROM
RORDLIN OL
INNER JOIN
RMAEBOD B
ON
B.CIACOD = OL.CIACOD
AND
B.MAECOD = OL.MAECOD
WHERE
EXISTS(
SELECT
1
FROM
RORDCAB OC
WHERE
OC.ORDEST = 'A'
AND
OC.ORDFS = 'N'
AND
OC.CIACOD = OL.CIACOD
AND
OC.ORDID = OL.ORDID
AND
OC.ORDSEC = OL.ORDSEC
)
AND
B.BDGID = 1
AND
SUM(OL.ORDCANT) - SUM(OL.ORDENT) <> B.MAEPED
GROUP BY
OL.MAECOD, B.MAEPED
ORDER BY
OL.MAECOD
|