SQL Select Statement For Calculating A Running Average Column

前端 未结 7 863
-上瘾入骨i
-上瘾入骨i 2020-12-11 04:53

I am trying to have a running average column in the SELECT statement based on a column from the n previous rows in the same SELECT statement. The average I need is based on

7条回答
  •  無奈伤痛
    2020-12-11 05:33

    Alternatively you can denormalize and store precalculated running values. Described here:

    http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/01/23/denormalizing-to-enforce-business-rules-running-totals.aspx

    Performance of selects is as fast as it goes. Of course, modifications are slower.

提交回复
热议问题