The queries SQL (getSQL) can be executed in our database. But the execution of the QBSelect fails with the following error message:
Unknown errorCode 100 SQL Anywhere Error -854: Function or column reference to 'max' in the ORDER BY clause is invalid
Yet, this morning I succeeded by rewriting the query. I now use a subquery to retrieve the aggregate. Then I join the main query with the subquery and use the aggregate column with getColumn() for sorting: