--- a/sql/item_sum.cc 2007-07-19 17:20:54.000000000 +0100 +++ b/sql/item_sum.cc 2007-09-08 18:53:21.000000000 +0100 @@ -3367,7 +3367,7 @@ DBUG_ASSERT(fixed == 1); if (null_value) return 0; - if (!result.length() && tree) + if (no_appended && tree) /* Tree is used for sorting as in ORDER BY */ tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, left_root_right);