query-d82d4ec9980bc36342c452d14ec22f6a

rq turtle/ttl

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 for P31. Documentation fwiw - ?item a wdno:P31., which is pretty much saying ?stat is a member of the class of BestRank statements. I think we see it on WD mainly as I've used it; and for clauses like ?stat rdf:type wikibase:BestRank. is the same as ?stat a wikibase:BestRank.: Yes; it's shorthand for the predicate rdf:type, so for instance Simon Villeneuve@I'm going to take up too much of your time with another question : how to filter the results to avoid having localities included in others in this query ? : Thanks for the info !Tagishsimon@

Use at

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
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?coord") v7("?coordinate") v9("?coordinate_node") v2("?item"):::projected v1("?lat") v3("?loc") v6("?pop"):::projected v5("?pop2") v4("?stat") a1((" ")) c10(["wikibase:BestRank"]):::iri 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/P131"--> v3 v2 --"p:P2046"--> v4 v4 --"a"--> c10 v4 --"p:statement/value-normalized/P2046"--> v5 v5 --"wikibase:quantityAmount"--> v6 v2 --"p:P625"--> v7 v7 --"p:statement/P625"--> v8 v7 --"p:statement/value/P625"--> v9 v9 --"wikibase:geoLatitude"--> v1