SQL: use WHERE clause in OVER()?

前端 未结 2 2265
轮回少年
轮回少年 2021-02-19 16:25

How can I use WHERE clause to filter in the OVER clause?

i.e. from the following data

LoanID | Principal | Tenor | Amortizin         


        
2条回答
  •  星月不相逢
    2021-02-19 16:56

    If you're using SQL Server 2012, you'd be looking to specify ROWS/RANGE in your OVER:

    Further limits the rows within the partition by specifying start and end points within the partition. This is done by specifying a range of rows with respect to the current row either by logical association or physical association. Physical association is achieved by using the ROWS clause.

    Other database systems may have similar features. This feature is new in the 2012 version of SQL Server.

提交回复
热议问题