calculate moving average with user conditions

Hi

I have data which looks like below.

 

month  Sale

1           100

2           120

3            85

4            70

5            50

6            220

7            180

 

I need to calculate moving average base on user requirement where he can give whether it should be 3 months or 4 months calculating. For example if he calculates at month 1 with 3 months average then it should take sale figures of months 1,2,3 and should calculate averge for month 4 .   like wise it should take sales figures for  months of 2,3,4   to calculate average for month 5 .

please do help me on this.

 

Thank You

 

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.