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 (PARTITIONBYCUSTOMER_IDORDERBYTRAN_DTROWS2PRECEDING)
But I need to compute this on raw data.
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.