SQL: How to fill empty cells with previous row value?

前端 未结 5 2322
深忆病人
深忆病人 2020-12-08 22:35

I need to produce the column \"required\" in the following table using SQL without using loops and correlated sub queries. Is this possible in SQL 2008?

Date         


        
5条回答
  •  我在风中等你
    2020-12-08 23:05

    How about a left outer join on the same table where the date is less than the current one and the value is non-empty, ordered by date desc (limit 1), returning zero when null ? (No server available to test at the moment). Unless this counts as a sub-query...

提交回复
热议问题