Skip to content

GROUP BY Month(dateField) not working #482

@bobwoofix

Description

@bobwoofix

A valid H2 Database query is not working with JSQLParser.

Here is the original query:
SELECT SUM(orderTotalValue) as value, MONTH(invoiceDate) as month, YEAR(invoiceDate) as year FROM invoice.Invoices WHERE projectID = 1 GROUP BY MONTH(invoiceDate), YEAR(invoiceDate) ORDER BY YEAR(invoiceDate) DESC, MONTH(invoiceDate) DESC

Having pulled it to bits until we discovered which part was not working, we discovered the GROUP BY MONTH(invoiceDate), YEAR(invoiceDate) was the issue. Even with just GROUP BY MONTH(invoiceDate) it still didn't work.

The error thrown was:
sf. jsqlparser. parser. ParseException: Encountered " "(" "( "" at line 1, column 142. Was expecting one of: "LIMIT" . . . "ORDER" . . . "OFFSET" . . . "HAVING" . . . ";" . . . "," . . . ". " . . . ". " . . . "," . . . "HAVING" . . . "ORDER" . . . "LIMIT" . . . "OFFSET" . . . "LIMIT" . . . at net. sf. jsqlparser. parser. CCJSqlParser. generateParseException(CCJSqlParser. java:5359) at net. sf. jsqlparser. parser. CCJSqlParser. jj_consume_token(CCJSqlParser. java:5235) at net. sf. jsqlparser. parser. CCJSqlParser. Statement(CCJSqlParser. java:146) at net. sf. jsqlparser. parser. CCJSqlParserManager. parse(CCJSqlParserManager. java:38)

Have updated to the latest version - still not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions