[CR #333077] Queries containing a select with a group by with a case expression using a local variable, may return wrong results.
Workaround: Remove the use of the local variable in group by.