AVG() OVER
AVG() OVER is a SQL function in the Window Functions category. Windowed average — calculates moving or partitioned averages. The syntax is AVG(column) OVER (PARTITION BY column). It accepts column. It returns windowed average. A typical example: SELECT date, revenue, AVG(revenue) OVER (ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS rolling_7day_avg FROM daily_sales; -- 7-day rolling average of daily revenue A close relative is ROW_NUMBER(), which assigns a unique sequential integer to each row within its partition (1, 2, 3...). A close relative is RANK(), which similar to ROW_NUMBER but gives the same rank to equal values. Leaves gaps in ranking. A close relative is DENSE_RANK(), which like RANK but without gaps. Equal values get the same rank, and the next number follows sequentially. More about this category: Window/analytical functions — ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, NTILE. Related Window Functions entries: ROW_NUMBER(), RANK(), DENSE_RANK(), LAG(), LEAD(), NTILE(), SUM() OVER, COUNT() OVER.