Archmede
Archmede

Reputation: 1856

row_number() with alias doesn't work in H2

I'm writing a query using Querydsl which involves the row_number() window function. The following query works fine:

select row_number() over (partition by id)
from example_table ExampleTable

but as soon as I try to alias the selected column then an org.h2.jdbc.JdbcSQLSyntaxErrorException is thrown

select row_number() over (partition by id) as rownum
from example_table ExampleTable

I'm using io.r2dbc:r2dbc-h2:1.0.0.RELEASE which uses v2.1.214 of H2, com.h2database:h2:2.1.214.

Dialect: MySQL

Upvotes: 0

Views: 211

Answers (1)

Archmede
Archmede

Reputation: 1856

Turns out the issue was the me using the word rownum. Changing it to rowNumber fixed it, rownum must be a keyword in H2.

Upvotes: 0

Related Questions