94

Moving Average Orders

Hardwindow functionmoving averageROWS BETWEEN

Problem Description

Write a SQL query to calculate 3-order moving average for order amounts.

Expected Columns

  • id
  • order_date
  • amount
  • moving_avg

Example Output

| id | order_date | amount | moving_avg | |----|------------|--------|------------| | 1 | 2023-01-20 | 76500.0 | 76500.0 | | 2 | 2023-01-25 | 8850.0 | 42675.0 | | 3 | 2023-02-01 | 4500.0 | 29950.0 | | ... | ... | ... | ... |

Hints

Unlocks after 2 more attempts
Submit your solution to unlock hints
//#94 Moving Average Orders
Hard

Loading schema...

Loading editor...

No results yet

Run a query to see results