sparql-examples

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

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

062

rq turtle/ttl

Country aspect: Organizations for a specific country

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#>
# title: Organizations for a specific country
PREFIX target: <http://www.wikidata.org/entity/Q35>

SELECT
  ?number_of_authors
  ?number_of_works
  ?organization ?organizationLabel
WITH {  
  SELECT
    ?organization
    (COUNT(DISTINCT ?author) AS ?number_of_authors)
    (COUNT(DISTINCT ?work) AS ?number_of_works)
  WHERE {
    ?organization wdt:P17 target: .
    ?author wdt:P108 | wdt:P463 | wdt:P1416/wdt:P361* ?organization .
    ?work wdt:P50 ?author .
  }
  GROUP BY ?organization 
} AS %results
WHERE {
  INCLUDE %results
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,es,fr,jp,nl,no,ru,sv,zh". }
}
ORDER BY DESC(?number_of_authors) DESC(?number_of_works)

graph TD