Some dialects register a special function for the aggregate function 'avg'. For example, HSQLDialect calls {{registerFunction("avg", new AvgWithArgumentCastFunction("double"))}} which is used if {{avg}} appears in a select statement but not if {{avg}} appears in an {{order by}} statement which leads to wrong results.
For exampe, the following query {code...
This message was sent by Atlassian JIRA (v6.1-OD-09-WN#6144-sha1:62dfc48)