• Revenant (12/21/2013)


    Hugo Kornelis (12/21/2013)


    So how exactly does one "aggregate (...) those rows that had been processed BEFORE the current row" with LAG? . . .

    http://technet.microsoft.com/en-us/library/hh231256.aspx

    Not sure why you post that link. I know what LAG is, and what it does.

    It does not answer the question on how to aggregate rows (watch the plural) with a function that is designed to return the value from one of the preceding rows.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/