query-d82d4ec9980bc36342c452d14ec22f6a
So item by item, that would be: - requires you to get the date for each population statement, and check that there is not a more recently dated population statement.(Q1001672)Senneville The first and third are solved by adding DISTINCT into the select (since you do not materialise the P31/P279 value nor the P625 value in the SELECT). Solving the multiple BestRank population values - such as in : Ach. You have it all going on here. wdt:P31/wdt:P279* wd:Q486972 is going to give you duplicate rows, if the locality has two P31 values which are a subclass of Q486972. Any item in which there is more than one BestRank population will also give you duplicates. And any item with duplicate coordinates will, ditto. So you need to protect against all of these, sadly.Simon Villeneuve@ 19:13, 20 December 2022 (UTC)) talk (Simon Villeneuve. Can you (explain me|point me documentation) what it does ? ?stat2 a wikibase:BestRank.It's the first time I see an "a" in that kink of line : 23:44, 20 December 2022 (UTC)) talk (Tagishsimon, who explained this to me a couple of years ago ... not the easiest thing to google for :) --User:OravrattasAlso, h/t 23:30, 20 December 2022 (UTC)) talk (Tagishsimon --https://www.w3.org/TR/sparql11-query/#abbrevRdfType which is, the item is a member of the class of items having
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 rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?item ?pop
WHERE
{
?item wdt:P17 wd:Q16 ; # Canada
wdt:P31/wdt:P279* wd:Q486972 ; #how to filter ?
wdt:P131* ?loc ; # localités humaines
p:P2046 ?stat . #la propriété population est désormais associée à ?stat
?stat a wikibase:BestRank ; #ici, "a" est un raccourci pour "rdf:type". On demande donc que ?stat soit membre des affirmations BestRank
psn:P2046 ?pop2 . #unité normalisée
?pop2 wikibase:quantityAmount ?pop .
?item p:P625 ?coordinate. #la propriété coordonnées géographiques est désormais associée à ?coordinate
?coordinate ps:P625 ?coord. #la valeur de coordonnées géographiques est désormais associée à ?coord
?coordinate psv:P625 ?coordinate_node. #Une valeur spécifique de P625 est associée à ?coordinate_node
?coordinate_node wikibase:geoLatitude ?lat. #On associe la latitude de P625 à ?lat
filter (?lat < 45.7) #on ne garde que les latitudes plus petites que 45,7
}