on 10-10-2011 6:48 PM
Jovenes expertos tengo una consulta, tengo un query que utiliza un UNION ALL en las facturas de ventas, compras y notas de credito ya sea de compras o de ventas, la duda o consulta que tengo es como puedo hacer que las notas de credito o debito ya sean de ventas o compras se reflejen negativos.
Espero me haya dado a explicar el query es el siguiente:
SELECT T0.[U_datos], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
union all
SELECT T0.[U_Datos],T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
FROM OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
union all
Select T0.[U_Datos],T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
union all
Select T0.[U_Datos],T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
from OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
Y de antemano muy agradecido.
Con esto lo puedes hacer negativo
SELECT T0.[U_datos], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
union all
SELECT T0.[U_Datos],T1.[ItemCode], T1.[Dscription], -T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
FROM OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
union all
Select T0.[U_Datos],T1.[ItemCode], T1.[Dscription], -T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
union all
Select T0.[U_Datos],T1.[ItemCode], T1.[Dscription], -T1.[Quantity], T1.[LineTotal], T0.[U_Descripcion]
from OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[U_datos] ='0061210029'
Solo con el signo negativo antes del campo.
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
9 | |
9 | |
5 | |
4 | |
4 | |
3 | |
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.