Hi @tab can’t tell for sure, but maybe the QoQ in those versions are more restrictive? Since you are using an aggregate function (but not using the GROUP BY statement) to query, and your are not using the “HAVING” statement, this example should work for those functions. Could you test that please?
A quick rule of thumb with QoQ since the 5.4 update, some of the old quirky sql which used to work, might not work anymore, so when in doubt, approach QoQ like you would a normal RDBMS
I’m not sure how this ever worked, but using an alias in a where clause is not something most DB’s support. SQL Server, for instance, will throw an error. This is presumably because the select expressions are evaluated only after the where clause has filtered the results, creating a catch-22.
Furthermore, mixing aggregate and non-aggregate functions in your select may not an error, but it makes no sense and most DB’s will also throw an exception on that.
The “user lacks privilege” error appears to be what HSQLDB throws when you try to use an aliased column in the where clause of an aggregated select.