0

Somehow this is not the initial request I have put forward. Indeed there are similar requests however as per my previous and initial message I tried the examples already delivered and some how I am failing to understand the concept.

What I want is a 3-month rolling average on the price.

The table title tbl consisting of the following productID, priceMonth, Price

The SQL statement I am using is the following:

SELECT AVG(Price) over(partition by productID between 2 preceding and current row) 
as rolling_avg 
FROM tbl 
GROUP by priceMonth 
order by price

I am not sure if the syntax is correct as it is giving me the following error:

An alias was previously found. (near "rolling_avg").

Therefore I cordially ask you the following:

1) I cannot locate where the alias problem is, can I cordially ask your assistance?

2) Is the above sql statements addresses what I am looking for? i.e a 3month rolling average?

R.Cremona
  • 59
  • 1
  • 6

0 Answers0