Subqueries (SPARQL 1.1)

A subquery is a query within a query. Since a SPARQL graph pattern can include arbitrary connections between variables and resource identifiers, there isn’t as much need to have subquery as there is in other query languages. In fact, for basic SPARQL (i.e., without limit or aggregate functions), there is no need for subquery at all.

But subqueries can be useful when combining limits and aggregates with other graph patterns. A question has to be pretty complex to require a subquery in SPARQL. A subquery limits the scope of things like aggregators, orderings, and limits to just part of the query. Following along the example using customer sales above, we notice that some companies increased their sales from 2009 to 2010, ...

Get Semantic Web for the Working Ontologist, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.