在MySQL中使用排名函数会导致错误

时间:2019-03-25 14:18:45

标签: rank mysql-5.7

我正在按照MYSQL教程进行操作,以产生一个排名查询。我正在关注教程linked

当我此时运行他们的代码时,我得到一个错误。我对代码进行了一些更改,以反映我对数据库的权限

CREATE TEMPORARY TABLE t (
    val INT
);

INSERT INTO t(val)
VALUES(1),(2),(2),(3),(4),(4),(5);


SELECT 
    *
FROM
    t;

SELECT
    val,
    RANK() OVER (
        ORDER BY val
    ) my_rank
FROM
    t;

我运行第三个SQL时的错误消息是

An error occurred when executing the SQL command:
SELECT
    val,
    RANK() OVER (
        ORDER BY val
    ) my_rank
FROM
    t

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 val
    ) my_rank
FROM
    t' at line 3

        ORDER BY val
^
1 statement failed.

Execution time: 0.03s

我是否缺少数据库上的设置以启用排名?

谢谢

0 个答案:

没有答案