MySQL error: What is wrong with my syntax for ranking?

MySQL error: What is wrong with my syntax for ranking?

我的 MySQL 版本是 5.6。
我有一个 MySQL 查询出错,需要帮助才能理解我做错了什么。

这里是查询:

select images.thumbnail16x9_file,
       images.square_file,
       RANK() OVER (ORDER BY images.timestamp desc) rank
from images 
where images.media_id = 875021;

这是错误信息:

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 images.timestamp ) rank
from images where images.media' at line 3

如果我这样做,我会得到结果:

select images.thumbnail16x9_file,
       images.square_file
from images 
where images.media_id = 875021 ;

有什么见解吗?

看到你提到的 运行 MySQL 5.6,我将 5.6 的文档与 8.0 的文档进行了比较,发现 RANK() 函数在 MySQL 5.6 中可能不可用.

存在 MySQL 5.6 的文档 here, and for 8.0 exists here

在 8.0 中搜索 RANK() 函数 return 一个名为 Window 函数描述的部分似乎涵盖了 RANK() 函数,而在 5.6 中执行相同的搜索似乎没有return 关于函数的任何事情。我对此不是 100% 确定,但肯定会尝试在 5.6 文档中找到对 RANK() 函数的引用以进行澄清。