Skip to content
Advertisement

Using row_number update column value using previous row value

I have a table in hive contents are below

Now I want to update the to_d column where row_num > 1 using some conditions like below

Please don’t get me wrong I am just trying to help one of the other user’s question Updating column values based on the other table values in hive tables

I was trying this approach but I am unable proceed further from here

Advertisement

Answer

You can use LAG function like below

This will give you the desired result

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement