sparql-examples

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

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

004

rq turtle/ttl

Author aspect: coauthor map

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q97270>

#defaultView:Map
SELECT ?organization ?organizationLabel ?geo ?count ?layer
WITH {
  SELECT DISTINCT ?organization ?geo (COUNT(DISTINCT ?work) AS ?count) WHERE {
    ?work wdt:P50 target: ;
          wdt:P50 ?author .
    FILTER (?author != target: )
    ?author ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* ?organization . 
    ?organization (wdt:P625 | ((wdt:P276|wdt:P159)/wdt:P625)) ?geo .
  }
  GROUP BY ?organization ?geo ?count
  ORDER BY DESC (?count)
  LIMIT 2000
} AS %organizations
WHERE {
  INCLUDE %organizations
  BIND(IF( (?count < 1), "No results", IF((?count < 2), "1 result", IF((?count < 11), "1 < results ≤ 10", IF((?count < 101), "10 < results ≤ 100", IF((?count < 1001), "100 < results ≤ 1000", IF((?count < 10001), "1000 < results ≤ 10000", "over 10000 results") ) ) ) )) AS ?layer )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }        
 }
ORDER BY DESC (?count)


graph TD