buenas dias amigos de SAP es que me solicitaron generar un informe para el pago de comisiones de los empleados de ventas me solicitarion estos campos en el requerimiento
hasta el momento tengo el codigo asi pero no se como incluir la suma del gasto Cta(5) costo Cta(6) e ingreso Cta(4) y relacionarlos con los proyectos que la forma en que se relacionan.
alguien maneja este tipo de informe que por favor me colabore a unir la información gracias
SELECT DISTINCT T0.[DocNum],
T0.[DocDate],
T3.[DocNum],
T0.[CardCode],
T0.[CardName],
T5.[Project],
T6.[SlpName],
T0.[BaseAmnt],
T0.[PaidSum],
T0.[DocTotal],
T3.[LocTotal] as "Pagado"
FROM OINV T0
LEFT JOIN OJDT T1 ON T0.[TransId] = T1.[TransId]
LEFT JOIN ITR1 T2 ON T1.[TransId] = T2.[TransId]
LEFT JOIN INV1 T5 ON T0.[DocEntry] = T5.[DocEntry]
LEFT JOIN OSLP T6 ON T0.[SlpCode] = T6.[SlpCode]
LEFT JOIN
(SELECT DISTINCT TA.[DocNum], TB.[LocTotal],TC.TransId, TC.ReconNum
FROM ORCT TA
INNER JOIN OJDT TB ON TA.[TransId] = TB.[TransId]
INNER JOIN ITR1 TC ON TB.[TransId] = TC.[TransId]
) T3 ON T2.ReconNum = T3.ReconNum
ya tengo el código hasta aquí pero necesito que la ultima columna me muestre el total repetido en todas las filas ósea el total del ingreso que es 2,956,242,188.1402
SELECT T2.[DocNum],
T2.[DocDate],
T2.[DocStatus],
T2.[CardCode],
T2.[CardName],
T2.[BaseAmnt],
T2.[PaidSum],
T2.[DocTotal],
sum(T1.[Credit])-sum(T1.[Debit])AS SUMA_ingreso FROM OJDT T0
left JOIN JDT1 T1 ON T0.[TransId]= T1.[TransId]
left JOIN OINV T2 ON T0.[TransId] = T2.[TransId]
left JOIN
( select * from INV1 TA) T3 ON T2.[DocEntry] = T3.[DocEntry] AND T0.[Project] = T3.[Project]
--LEFT JOIN ITR1 T4 ON T0.[TransId] = T4.[TransId]
LEFT JOIN OSLP T5 ON T2.[SlpCode] = T5.[SlpCode]
LEFT JOIN ORCT T7 ON T0.[TransId] = T7.[TransId]
/*left JOIN
(SELECT DISTINCT TA.[DocNum], TB.[LocTotal],TC.TransId, TC.ReconNum--,TE.[Credit],TE.[Debit],TE.[Project]
FROM ORCT TA
LEFT JOIN OJDT TB ON TA.[TransId] = TB.[TransId]
LEFT JOIN ITR1 TC ON TB.[TransId] = TC.[TransId]
--INNER JOIN JDT1 TE ON TB.[TransId] = TE.[TransId]
) T6 ON T4.ReconNum = T6.ReconNum */
WHERE T1.[Project] = 'ITPR-2019-054' and T1.[Account] LIKE '4%'
GROUP BY T2.[DocNum],
T2.[DocDate],
T2.[DocStatus],
T2.[CardCode],
T2.[CardName],
T2.[BaseAmnt],
T2.[PaidSum],
T2.[DocTotal]