• Your CASE statements need to match in the select & group by clauses - you have @Level = 6 in the select, and @Level < 6 in the group by.