query-9c769e0fe3e7f596457e9d34bdb5db1b
Sum a columnHi guys ! Sorry to bother you with this, but I can't find anywhere the answer. I want only one ?pop by item (the most recent one) and SUM all the values of the ?pop in this query :
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/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?itemLabel ?lat ?pop
WHERE
{
?item wdt:P17 wd:Q16 ;
wdt:P31/wdt:P279* wd:Q486972 ;
wdt:P1082 ?pop ;
p:P625 ?coordinate.
?coordinate ps:P625 ?coord.
?coordinate psv:P625 ?coordinate_node.
?coordinate_node wikibase:geoLatitude ?lat.
filter (?lat < 45.7)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
group by ?item ?itemLabel ?lat ?pop
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"):::projected
v1("?lat"):::projected
v3("?pop"):::projected
a1((" "))
c3(["wd:Q16"]):::iri
c6(["wd:Q486972"]):::iri
c13(["bd:serviceParam"]):::iri
c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal
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
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end