Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
i'm trying to execute a query on a table in H2 database with ROW_NUMBER clause. Here is my query:
SELECT ROW_NUMBER() OVER (order by data), name FROM students
But i get an error in H2 console:
Syntax error in SQL statement "SELECT ROW_NUMBER() OVER (order[*] by data), name FROM students"; expected ")";
I noticed that it only works if OVER clause is empty like OVER();
Any ideas?
This is not supported in the H2 database before V1.4.198 (release February 2019). You would need to use:
select rownum(), name
from students
order by data
As of V1.4.198, support for ROW_NUMBER (and some other window functions) was added (see H2 Changelog), so now your query should work as expected.
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.