简体   繁体   中英

Big Query How to fill the cell value with the value from previous row

In BQ I have a table like this, and I would like to fill the Id_customer empty cells with values from row above.

在此处输入图像描述

with grouped_table as ( select date, day_of_week, inventory, count(inventory) over (order by date) as _grp from inventory_log ), final_table as( select date, day_of_week, inventory, _grp, first_value() over (partition by _grp order by date) as new_inventory from grouped_table ) select date, day_of_week, new_inventory from final_table

https://medium.com/towards-data-science/tips-and-tricks-how-to-fill-null-values-in-sql-4fccb249df6f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM