Libras, amo cuando me contestas asi de rapido xd
Muchas gracias, si funciona, pero otra duda, en realidad esa condicion la quiero integrar en mi siguiente consulta:
Código SQL:
Ver originalSELECT TRIM,Corte1,UMC1,SUM(Ton1)Ton1,Descripcion,Id_Contenedor,Ancho,UAncho,TrimCorte,Peso,Rollos FROM(
SELECT DISTINCT TRIM,Corte1,UMC1,Ton1 FROM protri01 WHERE PedPipsa1 = '2070713'
UNION SELECT DISTINCT TRIM,Corte2,UMC2,Ton2 FROM protri01 WHERE PedPipsa2 ='2070713'
UNION SELECT DISTINCT TRIM,Corte3,UMC3,Ton3 FROM protri01 WHERE PedPipsa3 = '2070713'
UNION SELECT DISTINCT TRIM,Corte4,UMC4,Ton4 FROM protri01 WHERE PedPipsa4 ='2070713'
UNION SELECT DISTINCT TRIM,Corte5,UMC5,Ton5 FROM protri01 WHERE PedPipsa5 = '2070713'
UNION SELECT DISTINCT TRIM,Corte6,UMC6,Ton6 FROM protri01 WHERE PedPipsa6 ='2070713'
UNION SELECT DISTINCT TRIM,Corte7,UMC7,Ton7 FROM protri01 WHERE PedPipsa7 = '2070713'
UNION SELECT DISTINCT TRIM,Corte8,UMC8,Ton8 FROM protri01 WHERE PedPipsa8 ='2070713'
UNION SELECT DISTINCT TRIM,Corte9,UMC9,Ton9 FROM protri01 WHERE PedPipsa9 = '2070713'
UNION SELECT DISTINCT TRIM,Corte10,UMC10,Ton10 FROM protri01 WHERE PedPipsa10 ='2070713'
UNION SELECT DISTINCT TRIM,Corte11,UMC11,Ton11 FROM protri01 WHERE PedPipsa11 = '2070713'
UNION SELECT DISTINCT TRIM,Corte12,UMC12,Ton12 FROM protri01 WHERE PedPipsa12 ='2070713' ) C
INNER JOIN
(SELECT DISTINCT Descripcion,Id_Contenedor,Ancho,UAncho,TRIM AS TrimCorte,SUM(Peso) Peso ,COUNT(Id_Lote) Rollos
FROM prolot01 A INNER JOIN catpap01 B ON B.Id_Papel = A.Id_Papel
WHERE PedidoPIPSA= '2070713'AND Peso > 0 AND DevProd = 0 AND Jagenberg = 0 AND Detenido = 0 AND Rechazado = 0
GROUP BY Id_Contenedor,Ancho,UAncho,A.TRIM,B.Descripcion)D
ON C.TRIM = D.TrimCorte AND Corte1 = Ancho AND UMC1 = UAncho GROUP BY TRIM,Corte1,UMC1,Descripcion,Id_Contenedor,Ancho,UAncho,TrimCorte,Peso,Rollos
Cuando ejecuto esta query, que es la que realmente necesito, me regresa lo siguiente:
lo cual me retorna solo 5 toneladas de 63.5 cm, pero quiero que ahi me de el total, es decir, en lugar de 5 que me muestre los 10 que enrealidad existen.
Sabes como hacerlo? :(
edit:
Si lo meto asi:
Código SQL:
Ver originalSELECT TRIM,Corte1,UMC1,SUM(Ton1)Ton1,Descripcion,Id_Contenedor,Ancho,UAncho,TrimCorte,Peso,Rollos FROM(
SELECT DISTINCT TRIM,Corte1,UMC1,Ton1 FROM protri01 WHERE PedPipsa1 = '2070713'
UNION SELECT DISTINCT TRIM,Corte2,UMC2,Ton2 FROM protri01 WHERE PedPipsa2 ='2070713'
UNION SELECT DISTINCT TRIM,Corte3,UMC3,Ton3 FROM protri01 WHERE PedPipsa3 = '2070713'
UNION SELECT DISTINCT TRIM,Corte4,UMC4,Ton4 FROM protri01 WHERE PedPipsa4 ='2070713'
UNION SELECT DISTINCT TRIM,Corte5,UMC5,Ton5 FROM protri01 WHERE PedPipsa5 = '2070713'
UNION SELECT DISTINCT TRIM,Corte6,UMC6,Ton6 FROM protri01 WHERE PedPipsa6 ='2070713'
UNION SELECT DISTINCT TRIM,Corte7,UMC7,Ton7 FROM protri01 WHERE PedPipsa7 = '2070713'
UNION SELECT DISTINCT TRIM,Corte8,UMC8,Ton8+Ton9 AS Ton8 FROM protri01 WHERE PedPipsa8 ='2070713'
--union select distinct Trim,Corte9,UMC9,Ton9 from protri01 where PedPipsa9 = '2070713'
UNION SELECT DISTINCT TRIM,Corte10,UMC10,Ton10 FROM protri01 WHERE PedPipsa10 ='2070713'
UNION SELECT DISTINCT TRIM,Corte11,UMC11,Ton11 FROM protri01 WHERE PedPipsa11 = '2070713'
UNION SELECT DISTINCT TRIM,Corte12,UMC12,Ton12 FROM protri01 WHERE PedPipsa12 ='2070713' ) C
INNER JOIN
(SELECT DISTINCT Descripcion,Id_Contenedor,Ancho,UAncho,TRIM AS TrimCorte,SUM(Peso) Peso ,COUNT(Id_Lote) Rollos
FROM prolot01 A INNER JOIN catpap01 B ON B.Id_Papel = A.Id_Papel
WHERE PedidoPIPSA= '2070713'AND Peso > 0 AND DevProd = 0 AND Jagenberg = 0 AND Detenido = 0 AND Rechazado = 0
GROUP BY Id_Contenedor,Ancho,UAncho,A.TRIM,B.Descripcion)D
ON C.TRIM = D.TrimCorte AND Corte1 = Ancho AND UMC1 = UAncho GROUP BY TRIM,Corte1,UMC1,Descripcion,Id_Contenedor,Ancho,UAncho,TrimCorte,Peso,Rollos
Observe la linea 10, si hago esto si me da total 10, pero quiero condicionar, que lo haga cuando la medida sea igual. Tal como el primer ejemplo