Hello,
Could anyone help me on writing a SQL statement to get the following data?
Originally, I have a data set:
Key | Period | rowValue
1 | 2003/01 | 5
2 | 2003/02 | 8
3 | 2003/03 | 20
4 | 2003/04 | 10
5 | 2003/05 | 7
...
And want to have a desired dataset:
Key | Period | rowValue | previous_3_mth_sum
3 | 2003/03 | 20 | 33 (which is 5+8+20)
4 | 2003/04 | 10 | 38 (which is 8+20+10)
5 | 2003/05 | 7 | 37 (which is 7+10+20)
...
Im showing rows for all different periods, but these fields need to be looking back 3 months respective to the specific row, and will therefore not be the same for all rows.
Many Thanks!
Could anyone help me on writing a SQL statement to get the following data?
Originally, I have a data set:
Key | Period | rowValue
1 | 2003/01 | 5
2 | 2003/02 | 8
3 | 2003/03 | 20
4 | 2003/04 | 10
5 | 2003/05 | 7
...
And want to have a desired dataset:
Key | Period | rowValue | previous_3_mth_sum
3 | 2003/03 | 20 | 33 (which is 5+8+20)
4 | 2003/04 | 10 | 38 (which is 8+20+10)
5 | 2003/05 | 7 | 37 (which is 7+10+20)
...
Im showing rows for all different periods, but these fields need to be looking back 3 months respective to the specific row, and will therefore not be the same for all rows.
Many Thanks!