on 08-10-2016 6:14 PM
Hola.
Estoy trabado con una query, donde necesito me muestre el resultado de las facturas que tienen un producto especifico y un lote especifico.
La que desarrollo me muestra más facturas (un total de 9) siendo que sólo 2 tienen esas condiciones entregadas.
La query es la siguiente:
SELECT
T0.[DocNum],
T0.[DocDate],
T0.[CardCode],
T1.[ItemCode],
T1.[Dscription],
T1.[Quantity],
T1.[unitMsr]
FROM OINV T0 INNER JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry] INNER JOIN OITM T2 ON T1.[ItemCode] = T2.[ItemCode] INNER JOIN OBTN T3 ON T2.[ItemCode] = T3.[ItemCode]
WHERE T1.[ItemCode] ='pt-2020' and T3.[DistNumber] ='PT-20203336-1'
El resultado es el de la foto, cuando debiese mostrar sólo las facturas de la linea 1 y la linea 9 que cumplen esas condiciones.
Intenta con esto, en lo personal me funciona
SELECT
T1.[DocEntry],T0.[DocNum],T0.[DocDate],T0.[CardCode],T0.[CardName],
T1.[ItemCode],T1.[Dscription],T1.[Quantity],T1.[unitMsr],T2.BatchNum
FROM OINV T0 INNER JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN IBT1 T2 on T1.DocEntry =T2.BaseEntry and T1.ItemCode=T2.ItemCode and T1.LineNum=T2.BaseLinNum
WHERE T1.[ItemCode] ='PT0016' and T2.[BatchNum] ='ABC'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gracias, le agrego los datos que se buscan, pero sólo muestra un documento (factura), siendo que son dos facturas que tienen ese producto con ese lote especifico.
En este caso ocurre al revés, muestra sólo un dato, siendo que a mi me muestra datos de más...
Como se muestra el resultado de mas arriba en la foto, hay dos facturas con esa condición "producto y lote" con la query que me facilitas muestra sólo la factura 7538966 pero no la 7538161 que también cumple las condiciones.
Hola Daniel!!
Que te muestra la consulta si al select le agregas el "DistNumber"?
Saludos!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Daniel
Prueba con el campo BatchNum
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
SELECT
T1.[DocEntry],
T0.[DocNum],
T0.[DocDate],
T0.[CardCode],
T0.[CardName],
T1.[ItemCode],
T1.[Dscription],
T1.[Quantity],
T1.[unitMsr],
T3.[DistNumber]
FROM OINV T0 INNER JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry] INNER JOIN OITM T2 ON T1.[ItemCode] = T2.[ItemCode] INNER JOIN OBTN T3 ON T2.[ItemCode] = T3.[ItemCode]
WHERE T1.[ItemCode] ='pt-2020' and T3.[DistNumber] ='PT-20203336-1'
Gracias por tu tiempo-
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.