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

前端 未结 5 2267
深忆病人
深忆病人 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:19

    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?

    Impossible. Point. Not possibly on ANY SQL based server, including oracle.

    The main problem here is that you rule out loops AND correlated subqueries and any way to retrieve the value at query time will ultimately use another query to find the valid value (actually one per field). This is how SQL works. Yes, you could hide them in a custom scalar function, but still they would contain a logical sub query.

提交回复
热议问题