Fix query aggregate function.