我尝试使用AVG和OVER来平均获得7天,但被卡住了。 我不知道这是怎么回事。
您能帮我发现问题吗?
SELECT
dt
, SUM(purchase_amount) as total_amount
, AVG(SUM(purchase_amount))
OVER(ORDER BY dt
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as seven_day_avg
FROM purchase_log
GROUP BY dt
ORDER BY dt
ERROR:
Error Code: 1064. You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near
'(ORDER BY dt row between 6 preceding and current row) as seven_day_avg ' at line 5