I have an excel sheet that actually does the avarage on above 3 rows and displays in 4th row and followed entire Column. That means in the Formula row (for the first time it will have the row 1,2 and row 3) is empty and does the Average. The same i tried in SQL to display the Avarage on the same row... However I am not able to show the results on the same row...But the result are comming in 1st row instead of 4th row.From Excel I have the Formula is =SUM(B2:B4)/3 I am doing avarage for B Column on G Column For the same i have writen the SQL as below WITH RankedPricesAS(SELECT i_serial , I_Open, ROW_NUMBER() OVER (ORDER BY i_serial) AS rnFROM IC_Raw_In) SELECT a.i_serial, AVG(b.I_Open) AS AvgPrice FROM RankedPrices AS a INNER JOIN RankedPrices AS b ON b.rn BETWEEN a.rn AND a.rn + 2 GROUP BY a.i_serial
---IC_Raw_In table has B column data