Delete Or Change Records In Etl
I have a table over which I have built an ETL service. Goods records (arrival / departure) go to the table. I have done that my table will be erased. When the item identifier arriv
Solution 1:
To meet both your requirements you should check for change in cost like below
; with todelete as (
select *,
count(*) over (partition by label) as cnt,
lag(cost) over (partition by label order by time ASC) as lastcost
ROW_NUMBER() over (partition by label order by time ASC) as r_number
from Table1
)
delete from todelete
where cnt > 1 and r_number between 1 and (cnt/2)*2 and cost=ISNULL(lastcost,cost)
Post a Comment for "Delete Or Change Records In Etl"