LEAD & LAG analytic function
Example of LEAD and LAG analytic functions used to determine previous and next records
Example of LEAD and LAG analytic functions used to determine previous and next records
–USE ANALYTIC FUNCTION TO DELETE ALL BUT ORIGINAL delete from <TABLE_NAME> where (key1, ins_timestamp) in (select key1, ins_timestamp from ( select key1, ins_timestamp, upd_timestamp , row_number() over (partition by key1 order by ins_timestamp) as rownumber from <TABLE_NAME> ) t1 where …