tsql - T-SQL import data and remove duplicate records from prior month -


every month receive roster run queries on , generate data gets uploaded table outside source retrieve. question easiest way remove duplicate data prior months upload bearing in mind not data duplicated , if person not appear on new roster prior month needs remain. data time stamped when gets uploaded.

thank you

you can use cte , row_number() identify , remove dupes

;with cte (     select *           ,rn = row_number() on (partition somekeyfield(s) order somedate desc)       yourtable ) select *      -- << remove if satisfied -- delete     -- << remove comment if statisfied  cte   rn>1 

without seeing data structure, take hard partition , order within on clause of row_number()


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -