Help needed to compute Moving Average

Tools
Visitor

Help needed to compute Moving Average

I need to compute moving average(and few more statitistics) on the raw data for the 3 day moving window. I cannot roll up my data on customer id and transaction date level. The following syntax will work if I have the data rolled up as daily aggregates-

SyntaxEditor Code Snippet

AVG(TRAN_AM) OVER (PARTITION BY CUSTOMER_ID ORDER BY TRAN_DT ROWS 2 PRECEDING)

But I need to compute this on raw data. 

 

For example:

The input data comprises of customer_id, tran_dt and tran_am. Moving average need to computed as below, where 120 is the average of customer 100's transactions during dec1, dec2 and dec3. 100+200+100+100+100/5=120. Any help is greatly appreciated.

CUSTOMER IDTRAN_DTTRAN_AMMOV AVG
10012/1/2016$100$120
10012/1/2016$200$120
10012/2/2016$100$120
10012/3/2016$100$120
10012/3/2016$100$120
10012/4/2016$200$440
10012/5/2016$500$440
10012/5/2016$650$440
10012/5/2016$750$440
10012/6/2016$100$440
20012/1/2016$300$386
20012/2/2016$400$386
20012/2/2016$333$386
20012/3/2016$344$386
20012/3/2016$554$386
20012/5/2016$120$324
20012/5/2016$340$324
20012/6/2016$120$324
20012/6/2016$150$324
20012/7/2016$890$324