Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Difference between ROWS UNBOUNDED PRECEDING And ROWS BETWEEN 2 PRECEDING AND CURRENT ROW RE: Difference between ROWS UNBOUNDED PRECEDING And ROWS BETWEEN 2 PRECEDING AND CURRENT ROW

  • Eirikur Eiriksson (7/14/2014)


    The answer depends, the default framing of a window function varies depending on the function. As an example, the first_value function has the default framing of rows between unbounded preceding (all previous) and unbounded following (all subsequent) rows, while last_value has the default framing of unbounded preceding and current row. Not to be mixed with the equal syntax for range either.

    As an example, a running total would be calculated with the framing of unbounded preceding and current row, if it was set to unbounded preceding and unbounded following, it would be the default framing for a total sum for the partition. Let me know if I'm muddling the water here:-P

    😎

    That's correct 😛

    Thanks