sparql-examples

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

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

171

rq turtle/ttl

Sponsor aspect: recently published sponsored works

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX target: <http://www.wikidata.org/entity/Q1200258>

SELECT ?publication_date ?number_of_citations 
?work ?workLabel (CONCAT("/work/", SUBSTR(STR(?work), 32)) AS ?workUrl)
?quote
WITH {
  SELECT (MIN(?date) AS ?publication_date) (COUNT(?citing_work) as ?number_of_citations) ?work (SAMPLE(?quote_) AS ?quote)
  WHERE {
    ?work p:P859+ ?sponsor_statement .
    ?sponsor_statement ps:P859+ target: .
    OPTIONAL { ?sponsor_statement prov:wasDerivedFrom/pr:P1683 ?quote_ . }
    OPTIONAL {
      ?work wdt:P577 ?datetime .
      BIND(xsd:date(?datetime) AS ?date)
    }
    OPTIONAL { ?citing_work wdt:P2860 ?work }
  } 
  GROUP BY ?work
} AS %result
WHERE {
  INCLUDE %result
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" }
} 
ORDER BY DESC(?publication_date) DESC(?number_of_citations)
LIMIT 1000

graph TD