sql - Mean Of Sum Of Upper Rows -


i expect me.

i made table data, no need know in particual. come #temptable1:

week_number         sum         mean_of_sum --------------------------------------------------------------------------- 1                   10   2                   20   3                   30   4                   60   5                   30   6                   60   7                   0    

my desired table #temptable1:

week_number         sum         mean_of_sum --------------------------------------------------------------------------- 1                   10          10 --(10/1) 2                   20          15 --(30/2) 3                   30          20 --(60/3) 4                   60          30 --(120/4) 5                   30          30 --(150/5) 6                   60          35 --(210/6) 7                   0           30 --(210/7) 

i tried sums , expected group clause work, not. has idea on how solve ?

i think looking cumulative average:

select t.*, avg(sum*1.0) on (order week_number) t; 

this doesn't match last value. i'm guessing typo.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -