sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

110

rq turtle/ttl

Organization aspect: awards

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX hint: <http://www.bigdata.com/queryHints#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#defaultView:Table

PREFIX target: <http://www.wikidata.org/entity/Q104785223>

SELECT
  ?count
  ?award ?awardLabel
  ?recipients ?recipientsUrl
WITH {
  SELECT
    (COUNT(?researcher) AS ?count)
    ?award
    (GROUP_CONCAT(?researcher_label; separator=", ") AS ?recipients)
    (CONCAT("../authors/", GROUP_CONCAT(DISTINCT SUBSTR(STR(?researcher), 32); separator=",")) AS ?recipientsUrl)
  WHERE {
    hint:Query hint:optimizer "None" .
    {
      SELECT DISTINCT ?researcher WHERE {
        ?researcher ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* target: .
      } 
    }
    ?researcher wdt:P166 ?award .
    ?researcher rdfs:label ?researcher_label . FILTER (LANG(?researcher_label) = 'en')
  }
  GROUP BY ?award
} AS %result
WHERE {
  INCLUDE %result
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . } 
}
ORDER BY DESC(?count)

graph TD