sparql-examples

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

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

058

rq turtle/ttl

Country aspect: authors

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/Q35>

SELECT
  ?number_of_citing_works
  ?author ?authorLabel
  ?organization ?organizationLabel
  ?example_work ?example_workLabel
WITH {
  SELECT DISTINCT ?author WHERE {
    ?author wdt:P27 | wdt:P1416/wdt:P17 | wdt:P108/wdt:P17 target: .
  }
} AS %authors
WITH {
  SELECT
    ?author 
    (COUNT(DISTINCT ?citing_work) AS ?number_of_citing_works)
    (SAMPLE(?organization_) AS ?organization)
    (SAMPLE(?work) AS ?example_work)
  WHERE {
    INCLUDE %authors
    ?work wdt:P50 ?author .
    OPTIONAL { ?citing_work wdt:P2860 ?work . }
    OPTIONAL {
      ?author wdt:P1416 | wdt:P108 ?organization_ .
      ?organization_ wdt:P17 target:
    }
  }
  GROUP BY ?author 
} AS %results
WHERE {
  INCLUDE %results
  service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . } 
}
ORDER BY DESC(?number_of_citing_works) 
LIMIT 10000

graph TD