query-10f00bdcff44a7e4dc79f15e74c33e07
Total populationHello! I'm trying to sum the population of some municipalities, like in the Oresund example (that seems broken). But I can't find a way to do it. What I'm doing wrongly?
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?udalerria ?udalerriaLabel (SUM(?biztanleria) AS ?biztanleria_osoa) WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
{ ?udalerria wdt:P31 wd:Q2074737. }
UNION
{ ?udalerria wdt:P31 wd:Q484170. }
?udalerria wdt:P131*/^wdt:P527 wd:Q47588.
?udalerria wdt:P1082 ?biztanleria
}
group by ?udalerria ?udalerriaLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?biztanleria"):::projected
v3("?biztanleria_osoa")
v1("?udalerria"):::projected
a1((" "))
c6(["wd:Q2074737"]):::iri
c2(["bd:serviceParam"]):::iri
c9(["wd:Q47588"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c7(["wd:Q484170"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> c7
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"wdt:P31"--> c6
end
union0r <== or ==> union0l
end
v1 --"wdt:P131"--> a1
c9 --"wdt:P527"--> a1
v1 --"wdt:P1082"--> v2
bind1[/"sum(?biztanleria)"/]
v2 --o bind1
bind1 --as--o v3