SQL: Moving Average

Medium
SQL — Window Functions SQL Moving Average ROWS
Calculate 3-day moving average of stock prices.

Constraints

Write standard SQL (MySQL 8.0 compatible).

Examples

Example 1:
Input: day price 1 100 2 110 3 105
Output:
Example 2:
Input: day price 1 100 2 110 3 105
Output:

Hints

AVG with ROWS BETWEEN.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.