Either use an alias for the case statement that is not the same as the variable (t2.)MLR_ProduktgruppeID: i.e. ..AS MLR_ProduktgruppeID_2 and use the alias in the GROUP BY. Ambiguity between VAR and alias may be the issue AND/OR if that doesn't fix, also put the CASE statement longhand in the GROUP BY (without the AS...)
... View more