为什么不能使用 mysql 8.0.23 的 RDS 不允许 运行 window 函数?

Why cant RDS with mysql 8.0.23 doesn't allow to run window functions?

我在 Amazon RDS 上使用 MySQL 8.0.23。

innodb_version 是 8.0.23 版本是 8.0.23 RDS 界面上显示的引擎名称是 My SQL Community

我可以使用像“WITH”这样的 CTE 表达式,但是当我尝试使用像这里提到的任何 window 函数时:https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html,它会抛出一个错误。我错过了什么?

作品:

with items as ( 
   select number from item where updated_date > current_date 
) 
select * from items 

不起作用:

select number, row_number() from item 

错误信息:

Query 1: 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 'from item limit 1000' at line 1

正如 mysql window function syntax 上的手册所说:

MySQL also supports nonaggregate functions that are used only as window functions. For these, the OVER clause is mandatory

row_number() 包含在此列表中,因此您必须提供一个 over 子句。幸运的是,如果您希望结果集是 window,您可以提供一个空的 over 子句,因此正确的语法是:

with items as ( 
   select number, row_number() over() as rownumber from item where updated_date > current_date 
) 
select * from items