Saludos a tod@s tengo un query que me duplica una linea al momento de sumar la columna de Dep. acumulada de activos fijos , SBO1.
Me podras sugerir alguna funcion que no permita la duplicidad en estos registros,
Adjunto consulta
SELECT
T1.[ItemCode] AS 'Num. Activo Fijo',
T1.[ItemName] AS 'Descripcion de Activo Fijo',
T3.[DocDate] AS 'Fecha de Compra',
T3.[CardCode] AS 'Codigo Proveedor',
T3.[CardName] AS 'Nombre del Proveedor',
T3.[U_FacSerie] AS 'Serie de Factura',
T3.[U_Facnum] AS 'Numero de Factura',
T2.[Price] AS 'Costo',
T1.[CapDate] AS 'Fecha de Capitalización',
T4.[UsefulLife] AS 'Vida Util',
T4.[DprType] AS 'CI. Amortización',
T5.[APC] AS 'Valor',
sum(T6.[OrdDprAmt]) AS 'Dep.Acumulada'
FROM [dbo].[OITM] T1
LEFT JOIN [dbo].[PCH1] T2 ON T1.[ItemCode] = T2.[ItemCode]
LEFT JOIN [dbo].[OPCH] T3 ON T2.[DocEntry] = T3.[DocEntry]
LEFT JOIN [dbo].[ITM7] T4 ON T1.[ItemCode] = T4.[ItemCode]
LEFT JOIN [dbo].[ITM8] T5 ON T1.[ItemCode] = T5.[ItemCode]
LEFT JOIN [dbo].[DRN2] T6 ON T1.[ItemCode] = T6.[ItemCode]
WHERE T1.[ItemType]='F' and T4.[PeriodCat]=2017
group by T1.[ItemCode] ,
T1.[ItemName],
T3.[DocDate] ,
T3.[CardCode] ,
T3.[CardName],
T3.[U_FacSerie],
T3.[U_Facnum] ,
T2.[Price] ,
T1.[CapDate] ,
T4.[UsefulLife],
T4.[DprType] ,
T5.[APC]
order by T1.[ItemCode] ,
T1.[ItemName],
T3.[DocDate] ,
T3.[CardCode] ,
T3.[CardName],
T3.[U_FacSerie],
T3.[U_Facnum] ,
T2.[Price] ,
T1.[CapDate] ,
T4.[UsefulLife],
T4.[DprType] ,
T5.[APC]