Wednesday, January 19, 2011

Delete Duplicate rows

WITH CTE (account,memo_number, DuplicateCount)


AS

(

SELECT account,memo_number, valdate,

ROW_NUMBER() OVER(PARTITION BY account,memo_number ORDER BY valdate desc) AS DuplicateCount

FROM inv1_transactions_bkp

)

DELETE

FROM CTE

WHERE DuplicateCount > 1

GO

No comments:

Post a Comment