This shows how one can pivot a SELECT result set in SPARQL to have columns which correspond to row values. The topic is hot in the SQL world so perhaps one day people will start wondering about it in SPARQL.
This query pivots the (type, number_of_instances) relation generated by the inner subquery.
It uses Stardog-specific functions (:set
and :index
) but it's probably not too hard to adapt group_concat
(just a little clumsier, left as an exercise for the reader :)
prefix : <tag:stardog:api:>