;WITH cte
AS (Select ROW_NUMBER() OVER (PARTITION BY Entity,ExpenseType,Amount,Description,APSupplierID,ExpenseReportID,Employee,ExpenseDate ORDER BY ( SELECT 0)) RowNum
FROM TotalsByGLCenter)
Delete FROM cte
WHERE RowNum > 1;
The “ROW_NUMBER()” in the above query returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. The “ORDER BY” clause determines the order in which the ROW_NUMBER value is assigned to the rows in a partition. The “PARTITION BY” clause used here to divide the result set into partitions;
The new column RowNum shows row numbers of the duplicate rows.
In case if you want to see the duplicate rows you can use select instead of delete
;WITH cte
AS (Select ROW_NUMBER() OVER (PARTITION BY Entity,ExpenseType,Amount,Description,APSupplierID,ExpenseReportID,Employee,ExpenseDate ORDER BY ( SELECT 0)) RowNum,Entity,ExpenseType,Amount,Description,APSupplierID,ExpenseReportID,Employee,ExpenseDate
FROM TotalsByGLCenter)
Select * FROM cte
WHERE RowNum > 1;