I am trying to learn about the MySQL ROW_NUMBER() function and how to use it to generate a sequential number for each row in a result set.
What I tried so far:
SELECT e.*,
ROW_NUMBER()
OVER(PARTITION BY e.examid ORDER BY e.examid) AS id
from exam e
When I run this query, a series of errors were displayed:
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
How can I go about it?