The optimization for "group by" was not working correctly if the group by column was aliased in the select list.