SPARQL/Modifiers

There are 4 optional modifiers to the. See the chapter on SELECT for an introduction.

The five modifiers are,  ,  ,   and.

GROUP BY
Let us consider this list of children of Bach, listing also their mother

Let us group this list by the mothers.

We  both variables   and   because if we would leave out the label we would end up with an error "Bad Aggregate".

First we added  to count the number of children. is one of the Aggregate functions,  ,  ,  ,   or. Notice first that it counts the variable. Notice as well that the syntax is.

As second information we added a combined list of children per mother by using.

When using  and a label, all labels should be defined explicitly in the SERVICE.

HAVING
is always used in combination with

will filter out groups that does not meet the condition specified. In this case only one mother is shown, with 13 children.

As  is bound to the variable   the   clause can also be written as.

The  clause can be useful for finding duplicates for instance like.

ORDER BY
sorts the results by. can be any expression or variables. This expression can also be wrapped in either  or   to specify the sorting order (ascending or descending). (If you don’t specify either, the default is ascending sort, so  is equivalent to just  .)

LIMIT
cuts off the result list at  results, where   is any natural number. For example,  limits the query to ten results. only returns a single result.

This could be useful to get the top 10 results, or only 10 random results to see how the data looks like.

OFFSET
can be used to skip the first number of results. returns records 101-110.