sparql-examples

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

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

158

rq turtle/ttl

Publisher aspect: journals

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
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#>
PREFIX target: <http://www.wikidata.org/entity/Q73820>

SELECT
  (SAMPLE(?number_of_works_) AS ?number_of_works)
  (MAX(?bfi) AS ?BFI)
  ?journal ?journalLabel
  (GROUP_CONCAT(?themes_labels; separator=", ") as ?theme)
WITH {
  SELECT 
    ?journal
    (COUNT(?work) AS ?number_of_works_)
  WHERE {
    ?journal wdt:P123 target: .
    OPTIONAL { ?work wdt:P1433 ?journal . }
  }
  GROUP BY ?journal 
} AS %journals
WHERE {
  INCLUDE %journals
  OPTIONAL {
    ?journal wdt:P921 ?themes .
    ?themes rdfs:label ?themes_labels .
    FILTER (LANG(?themes_labels) = 'en')
  }
  OPTIONAL { ?journal wdt:P1240 ?bfi . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . } 
} 
GROUP BY ?journal ?journalLabel
ORDER BY DESC(?number_of_works)

graph TD