query-d64531f73be6263e7ce3a39e8ff889db

rq turtle/ttl

Categories per origen de llocs d'Espanya i nombre d'articles (versiĆ³ millorable) SELECT DISTINCT ?lloc ?llocLabel ?cat ?categoria (COUNT(?persona) AS ?totpers) WHERE { ?persona wdt:P19 ?lloc. ?lloc wdt:P17 wd:Q29. ?art schema:about ?persona. ?art schema:isPartOf https://ca.wikipedia.org/. OPTIONAL { ?lloc wdt:P1464|wdt:P1792 ?cat. OPTIONAL { ?categoria schema:about ?cat. ?categoria schema:isPartOf https://ca.wikipedia.org/. } } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca,en,es" . } } GROUP BY ?lloc ?cat ?llocLabel ?categoria ORDER BY DESC(?totpers) ?llocLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Categories per origen de llocs d'Espanya i nombre d'articles (versiĆ³ millorable)
SELECT DISTINCT ?lloc ?llocLabel ?cat ?categoria  (COUNT(?persona) AS ?totpers)
    WHERE {
      ?persona wdt:P19 ?lloc.
      ?lloc wdt:P17 wd:Q29.
    ?art schema:about ?persona.
    ?art schema:isPartOf <https://ca.wikipedia.org/>.
  OPTIONAL {
    ?lloc wdt:P1464|wdt:P1792 ?cat.
  OPTIONAL {
    ?categoria schema:about ?cat.
    ?categoria schema:isPartOf <https://ca.wikipedia.org/>.
  }
    }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ca,en,es" . } 
      }
GROUP BY ?lloc ?cat ?llocLabel ?categoria
ORDER BY DESC(?totpers) ?llocLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?art") v6("?cat"):::projected v7("?categoria"):::projected v4("?lloc"):::projected v2("?llocLabel"):::projected v3("?persona"):::projected v8("?totpers") c3(["wd:Q29"]):::iri c10(["bd:serviceParam"]):::iri c6([https://ca.wikipedia.org/]):::iri c12(["#91;AUTO_LANGUAGE#93;,ca,en,es"]):::literal v3 --"wdt:P19"--> v4 v4 --"wdt:P17"--> c3 v5 --"schema:about"--> v3 v5 --"schema:isPartOf"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v4 -."wdt:P1792".-> v6 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v4 --"wdt:P1464"--> v6 end union0r <== or ==> union0l end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."schema:about".-> v6 v7 --"schema:isPartOf"--> c6 end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind1[/"count(?persona)"/] v3 --o bind1 bind1 --as--o v8