MySQL Workbench v8.0.1中无法使用RANK, OVER, WINDOW函数 &g



我正在使用MySQL Workbench v8.0.1,根据以下版本检查,仍然无法使用RANK(),DENSE_RANK(),WINDOW,OVER,PRECEDING,UNBOUNDED PRECEDING等功能,以及所有其他应该在v8.0及以上版本中支持的功能

我查询:

WITH daily_shipping_summary AS 
( 
SELECT ship_date, SUM(shipping_cost) AS daily_total FROM market_fact_full AS m
INNER JOIN shipping_dimen AS s
ON s.ship_id = m.ship_id
GROUP BY ship_date
)
SELECT *,
SUM(daily_total) OVER w1 AS running_total,
AVG(daily_total) OVER w2 AS moving_avg
FROM daily_shipping_summary
WINDOW w1 AS (ORDER BY daily_total ROWS UNBOUNDED PRECEDING),
w2 AS (ORDER BY daily_total ROWS 6 PRECEDING)

得到以下错误:
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 'w1 AS running_total, AVG(daily_total) OVER w2 AS moving_avg FROM daily_shipp' at line 10

谁能帮我解决这个问题?

MySQL工作台版本详细信息:

innodb_version8.0.1tls_versionTLSv1, TLSv1.18.0.1-dmr-logMySQL Community Server (GPL)

使用WINDOW这个词一次,然后在它后面执行name as (spec), name2 as (spec2)

例子如果您不打算重用窗口规范,请参阅关于内联的注释(或者即使规范被重用,大多数情况下也更倾向于内联,这是我们倾向于做的,因为它避免了在sql中跳转来确定什么是做什么的)

相关内容

  • 没有找到相关文章

最新更新