avg sale of quarter with previous quarter avg sale
I have a table one in which there are various attribute like region product,year,qtr,month,sale. I have to calculate the avg_qtr sale of each product having same region and show their previous avg_qtr sale.I have read about lag but here it is not possible to use as it is not fixed after how many rows it will be repeated. My table structure is like this Region Product Year Qtr Month Sales NORTH P1 2015 1 JAN 1000 NORTH P1 2015 1 FEB 2000 NORTH P1 2015 1 MAR 3000 NORTH P1 2015 2 APR 4000 NORTH P1 2015 2 MAY 5000 NORTH P1 2015 2 JUN 6000 NORTH P1 2015 3 JUL 7000 NORTH P1 2015 3 AUG 8000 NORTH P1