Index: /elgg/branches/elgg1.5-sql-fixes/engine/lib/annotations.php =================================================================== --- /elgg/branches/elgg1.5-sql-fixes/engine/lib/annotations.php (revision 364) +++ /elgg/branches/elgg1.5-sql-fixes/engine/lib/annotations.php (revision 378) @@ -680,8 +680,8 @@ $query .= get_access_sql_suffix("a"); // now add access $query .= ' and ' . get_access_sql_suffix("e"); // now add access - if (!$count) $query .= ' group by e.guid'; + if (!$count) $query .= ' group by e.guid, e.type, e.subtype, e.owner_guid, e.site_guid, e.container_guid, e.access_id, e.time_created, e.time_modified, e.enabled '; if (!$count) { - $query .= ' order by sum ' . $orderdir; + $query .= ' order by count(msvalue.id) ' . $orderdir; $query .= ' limit ' . $limit . ' offset ' . $offset; return get_data($query, "entity_row_to_elggstar");