query-70c328172288a4065cf54c06454c7389
title: Sammanlagd befolkning i Öresundsregionen
Illustrates the SUM aggregate function
SELECT DISTINCT ?area ?areaLabel (sum(?folkm_ngd) as ?total_folkm) # the first two variables can be removed # if only the number is needed WHERE { ?item wdt:P361 wd:Q297853. # part of (P361) Øresund Region (Q297853) ?item wdt:P1082 ?folkm_ngd. # population (P1082) ?area wdt:P31 wd:Q1907114. # instance of (P31) metropolitan area (Q1907114) ?area wdt:P527 ?item. # has part (P527) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } } GROUP BY ?area ?areaLabel
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#>
#title: Sammanlagd befolkning i Öresundsregionen
# <span lang="en" dir="ltr" class="mw-content-ltr">Illustrates the SUM aggregate function</span>
SELECT DISTINCT ?area ?areaLabel (sum(?folkm_ngd) as ?total_folkm) # <span lang="en" dir="ltr" class="mw-content-ltr">the first two variables can be removed</span>
# <span lang="en" dir="ltr" class="mw-content-ltr">if only the number is needed</span>
WHERE {
?item wdt:P361 wd:Q297853. # <span lang="en" dir="ltr" class="mw-content-ltr">part of (P361) Øresund Region (Q297853)</span>
?item wdt:P1082 ?folkm_ngd. # <span lang="en" dir="ltr" class="mw-content-ltr">population (P1082)</span>
?area wdt:P31 wd:Q1907114. # <span lang="en" dir="ltr" class="mw-content-ltr">instance of (P31) metropolitan area (Q1907114)</span>
?area wdt:P527 ?item. # <span lang="en" dir="ltr" class="mw-content-ltr">has part (P527)</span>
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
GROUP BY ?area ?areaLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?area"):::projected
v2("?folkm_ngd"):::projected
v1("?item")
v4("?total_folkm")
c2(["wd:Q297853"]):::iri
c5(["wd:Q1907114"]):::iri
c8(["bd:serviceParam"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
v1 --"wdt:P361"--> c2
v1 --"wdt:P1082"--> v2
v3 --"wdt:P31"--> c5
v3 --"wdt:P527"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end
bind1[/"sum(?folkm_ngd)"/]
v2 --o bind1
bind1 --as--o v4