Home > database >  How to update multiple columns in window frame based on other column value on same window frame
How to update multiple columns in window frame based on other column value on same window frame

Time:02-11

My Dataframe is something like below, trying to update all column values based on the highest version within that group. I am able to update at the complete table level but failed to update the in-group/window frame level.

source:

original-data-frame

expected output:

expected_data

CodePudding user response:

SELECT *, max_by(status, version) OVER (PARTITION BY number) AS updated_status FROM your_table

This should work for your case.

  • Related