Getting SQL Error: "SELECT" is not valid at this position for this server version, expecting '(' with

Getting SQL Error: "SELECT" is not valid at this position for this server version, expecting '(' with

我一直在 MySQL Workbench 中尝试以下查询:

SELECT NAME,LEAD,OUTCOME,COUNT(*) AS NUMBER_OUTCOME
FROM OUTCOMES_BY_USER
ORDER by NAME,LEAD,OUTCOME ASC;

但是我收到这个错误:

"SELECT" is not valid at this position for this server version, expecting '(' with

我试图通过删除部分查询并查看它在哪里中断来找出错误的来源,当我尝试时它似乎有效:

SELECT NAME
FROM OUTCOMES_BY_USER;

然而,当我添加另一列时(如下所示),我开始遇到同样的错误:

SELECT NAME, LEAD
FROM OUTCOMES_BY_USER;

我真的不确定如何解决这个错误,我在 sqlfiddle 中尝试这个查询并且它工作正常,但是我的 sqlfiddle 突然停止工作并且网站完全无法再为我构建模式。所以我在我的大学 MySQL 服务器上试用了它,但一直收到此错误。请帮忙!

LEAD() 是一个 MySQL 函数,因此它是一个保留字。您可以在保留 table 或列名周围添加反引号以绕过此错误:

SELECT NAME,`LEAD`,OUTCOME,COUNT(*) AS NUMBER_OUTCOME
FROM OUTCOMES_BY_USER
ORDER by NAME,`LEAD`,OUTCOME ASC;