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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access