query-43e9e3110f465b7fec9b086cfe22ad81
02:21, 11 December 2022 (UTC)) talk (Simon VilleneuveChatGPT give me that, but the problem is that the multiple values of ?pop of each item are summed. I only want one population value by item :
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT (SUM (?pop) as ?popSum)
WHERE
{
?item wdt:P17 wd:Q16 ; # Canada
wdt:P31/wdt:P279* wd:Q486972 ; # localités humaines
wdt:P1082 ?pop ; # population
p:P625 ?coordinate.
?coordinate ps:P625 ?coord.
?coordinate psv:P625 ?coordinate_node.
?coordinate_node wikibase:geoLatitude ?lat.
filter (?lat < 45.7)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?coord")
v4("?coordinate")
v6("?coordinate_node")
v2("?item")
v1("?lat")
v3("?pop"):::projected
v7("?popSum")
a1((" "))
c3(["wd:Q16"]):::iri
c6(["wd:Q486972"]):::iri
f0[["?lat < '45.7^^xsd:decimal'"]]
f0 --> v1
v2 --"p:direct/P17"--> c3
v2 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c6
v2 --"p:direct/P1082"--> v3
v2 --"p:P625"--> v4
v4 --"p:statement/P625"--> v5
v4 --"p:statement/value/P625"--> v6
v6 --"wikibase:geoLatitude"--> v1
bind2[/"sum(?pop)"/]
v3 --o bind2
bind2 --as--o v7