query-12dfe1ee05e30155fc4bf7c292ed88be
Categories per lloc de mort de llocs d'Espanya i nombre d'articles (1 nivell P131) SELECT DISTINCT ?lloc ?llocLabel ?cat ?categoria (COUNT(DISTINCT(?persona)) AS ?totpers) WHERE { ?persona wdt:P20/wdt:P131? ?lloc. ?lloc wdt:P17 wd:Q29. ?art schema:about ?persona. ?art schema:isPartOf https://ca.wikipedia.org/. OPTIONAL { ?lloc wdt:P1465 ?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
- https://query.wikidata.org/sparql
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 lloc de mort de llocs d'Espanya i nombre d'articles (1 nivell P131)
SELECT DISTINCT ?lloc ?llocLabel ?cat ?categoria (COUNT(DISTINCT(?persona)) AS ?totpers)
WHERE {
?persona wdt:P20/wdt:P131? ?lloc.
?lloc wdt:P17 wd:Q29.
?art schema:about ?persona.
?art schema:isPartOf <https://ca.wikipedia.org/>.
OPTIONAL {
?lloc wdt:P1465 ?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")
a1((" "))
c4(["wd:Q29"]):::iri
c10(["bd:serviceParam"]):::iri
c7([https://ca.wikipedia.org/]):::iri
c12(["#91;AUTO_LANGUAGE#93;,ca,en,es"]):::literal
v3 --"wdt:P20"--> a1
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
a1 --"wdt:P131"--> v4
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
end
union0r <== or ==> union0l
end
v4 --"wdt:P17"--> c4
v5 --"schema:about"--> v3
v5 --"schema:isPartOf"--> c7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P1465".-> v6
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v7 -."schema:about".-> v6
v7 --"schema:isPartOf"--> c7
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