I have 3 source table and have to union them all source 1:Id name car 1 aaa BMW 1 aaa Porche 1 aaa Nissan2 bbb Nissan2 bbb Hondasource 2:Id name car 1 aaa Camry source 3:Id name car 1 aaa Honda 1 aaa Ford 2 bbb BuickNow I want to combine them all and insert into a table with a sequence. this sequence will have incremental Value repeating for each ID.Target tableId name car sequence1 aaa BMW 11 aaa Porche 2 1 aaa Nissan 31 aaa Camry 41 aaa Honda 51 aaa Ford 62 bbb Nissan 12 bbb Honda 22 bbb Buick 3I know i have to use row_number() and partition by but unable to capture the sequence with Union with this function. How ever, I can insert them in temp table and create another temp table with row_number, it works fine. I unable to update the column with row_number() as well.I wanted to know if there is direct approach with union or if I can update the target table?
↧