我正在学习MySQL ROW_NUMBER()函数以及如何使用它来为结果集中的每一行生成一个顺序号。
目前我的尝试:
SELECT e.*,
ROW_NUMBER()
OVER(PARTITION BY e.examid ORDER BY e.examid) AS id
from exam e
当我运行这个查询时,出现了一系列错误:
3 errors were found during analysis.
An alias was previously found. (near "id" at position 68) An alias was expected. (near " " at position 67) Unexpected token. (near "id" at position 68)
#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 '(PARTITION BY examid ORDER BY examid) as id from exam LIMIT 0, 25' at line 1
我该怎样着手处理?
SELECT @@version;
- Bill Karwin