Skip to content
Advertisement

How to fix H2 Syntax error in SQL statement?

I asked earlier today about replacing a window function because H2 does not support it.

I rewrote SQL query but every time I get syntax error in the SQL query (posted below)

expected “UNION, MINUS, EXCEPT, INTERSECT, ORDER, OFFSET, FETCH, LIMIT, FOR, ).

Can you please tell where is error in this query?

Error in Intellij:

Advertisement

Answer

H2 supports window functions since 1.4.198. If you can upgrade H2 to a latest version (1.4.199) it’s better to do it instead of such workarounds with overcomplicated queries, they will be slower than a simple query with a window function.

Note that FROM table) part is invalid in recent versions of H2, because TABLE is a keyword, if you have a table with that name it needs to be quoted ("TABLE" or "table" depending on your settings).

If you’re really required to use some old unsupported version of H2 such as 1.4.197 or older, you need to post the complete error message here. It includes your SQL command with a [*] mark that indicates a place with a syntax problem.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement