Ola!
tengo el siguiente problema:
tengo una consulta sql asi:
Código SQL:
Ver originalSELECT DISTINCT G.id_gran AS 'ID',G.nom_gran AS 'NOMBRE', E.num_plan AS 'PLANILLA', L.id_lot AS 'LOTE', E.cil_ent AS 'NUMERO CILINDROS', E.pes_cil AS 'PESO B.ENTREGA', P.num_com_plan AS 'O.COMPRA', SUM(E.cil_ent) AS 'TOTAL CIL.ENTREGADOS', (SELECT DISTINCT ISNULL (LL.pes_cil,0) FROM Llenos AS LL WHERE P.id_plan=LL.num_plan AND E.id_cil=LL.id_cil) AS 'PESO B.RETIRO LLENO', (SELECT DISTINCT ISNULL (V.pes_cil, 0) FROM Vacios AS V WHERE P.id_plan=V.num_plan AND E.id_cil=V.id_cil) AS 'PESO B.RETIRO VACIO',(SELECT DISTINCT ISNULL (LL.pes_cil,0) FROM Llenos AS LL WHERE P.id_plan=LL.num_plan AND E.id_cil=LL.id_cil) AS 'PESO NO CONSUMIDO',(SELECT DISTINCT (E.pes_cil - LL.pes_cil)FROM Llenos AS LL WHERE P.id_plan=LL.num_plan AND E.id_cil=LL.id_cil) AS 'DIFERENCIA ENT-NO CONSU', P.num_com_plan AS 'O.COMPRA',SUM(E.cil_ent)AS 'TOTAL CIL.ENTREGADOS',SUM(E.pes_cil) AS'TOTAL PES.ENTREGADO',(SELECT DISTINCT SUM (LL.pes_cil)FROM Llenos AS LL WHERE P.id_plan=LL.num_plan AND E.id_cil=LL.id_cil)AS 'TOTAL PES.NO CONSUMIDO',(SELECT DISTINCT SUM(E.pes_cil) - SUM(LL.pes_cil)FROM Llenos AS LL WHERE P.id_plan=LL.num_plan AND E.id_cil=LL.id_cil) AS 'NETO A LIQUIDAR',(SELECT DISTINCT SUM(E.pes_cil) - SUM(LL.pes_cil)FROM Llenos AS LL WHERE P.id_plan=LL.num_plan AND E.id_cil=LL.id_cil)* 792 AS 'VALOR A LIQUIDAR'
FROM
Reporte AS R,Lote AS L,Planilla AS P,Entrega AS E,Granja AS G,Llenos AS LL
WHERE
G.id_gran=L.id_gran_lot AND L.id_lot=R.id_lot_rep AND P.id_rep_plan=R.id_rep AND P.id_plan=E.num_plan
GROUP BY
G.id_gran,G.nom_gran,E.num_plan,L.id_lot,E.cil_ent,E.pes_cil,
P.num_com_plan,P.id_plan,E.id_cil,LL.pes_cil
cuando quiero reemplazar los valores nulos por cero no me los toma y por esta razon no puedo hacer algunas operaciones que necesito, esto pasa en las subconsultas que tengo ahi
por favor alguien me puede ayudar muchas gracias