SPARQL/Bad aggregate

The error Bad aggregate might appear when coding mistakes upon using. See also the chapter modifiers for a description of.

The error "Bad aggregate" does not specify what exactly is the mistake, hence this explanation to help you find out the cause.

This is a correct example. This list the children of Bach, grouped by their mother:

The first condition is that the grouping variables should match. Try for yourself what happens when you use. At the bottom of the long list of the errors you might find the text "Non-aggregate variable in select expression: motherLabel". If the  is left out completely the error message is similar "Non-aggregate variable in select expression: mother".
 * In the  the grouping is by both variables   and.
 * In the  the same variables     should be listed.

The second condition is that the rest of the variables in the  should each result into one value. Try for yourself what happens when you change in the rest of the  code. If for instance you would use  you might find at the bottom of the long list of the errors the text "Non-aggregate variable in select expression: childLabel".
 * You need expressions that will result into one value, for instance  or one of the other Aggregate functions ,  ,   or.
 * You can also use  to list all values into one variable, as all values of   into.
 * All variables should be converted with expressions as described above, even if a variable has one value only.

The error message is always "Non-aggregate variable in select expression: xxxxx", whether a variable is missing from the  or  a variable not aggregated at the   clause.