query-a759d1beb393d70c14bf828ac140be21
22:35, 16 February 2019 (UTC)) talk (Andrew Gray has a P131 but it doesn't have a complete chain up to Ontario. (Q94904)Niagara Central Airport You also need to bring this bit inside the overall P131 optional clause, but once you've done that it works correctly. It shows the top-level admin area (if one exists). If it has a P131 but that doesn't link into a chain going up to a province/territory, then it's blank. eg/ . So P31:Q2879 won't match any items at all - you need to add an extra P279 line to match a province/territory.(Q2879)province or territory of Canada , which is a subclass of (Q11828004)province of Canada Edit conflicted, but here's my answer anyway :-) A problem here is that Ontario is an instance of 22:41, 16 February 2019 (UTC)) talk (Andrew Gray has two (one the province, one the town). I'm not quite sure how the / syntax works though so I can't see why. (Q338950)Bamfield Water Aerodrome has one value (not a province) and (Q94904)Niagara Central Airport doesn't quite seem to work as expected - it returns all the P131 values, regardless of whether they're a town or a province. So OPTIONAL { ?airport wdt:P131/ wd:Q2879 ?localisation_administrative. }: looking at these two queries, your Bouzinac@ OPTIONAL { ?airport wdt:P131 ?localisation_administrative.Hi there, thank you, I buy the 23:03, 16 February 2019 (UTC)) talk (Bouzinac The data is often poor on obscure airports… So data is not clean :/ ?localisation_administrative wdt:P31 ?type . ?type wdt:P279 wd:Q2879. }22:56, 18 February 2019 (UTC)) talk (Bouzinac renders an empty column… Any thoughts? .Q35657 ?airport wdt:P131 ?localisation_administrative. ?localisation_administrative wdt:P31 ?type. ?type wdt:P279 wd: does show any level of US territories [so does'nt limit to US States] but .Q852446?airport wdt:P131 ?localisation_administrative. ?localisation_administrative wdt:P31 ?type. ?type wdt:P279 wd:Hello again, I'm surprised by this code : 23:40, 18 February 2019 (UTC)) talk (Tagishsimon whereas if you're interested in Q852446 you require the P279 lookup. --.Q35657 ?airport wdt:P131 ?localisation_administrative. ?localisation_administrative wdt:P31 wd: so if you want to look for locations that are part of Q35657 only, you'd use (Q829)Utah Q35657 is a P279 of Q852446, but Q35657 has no useful P279 relation with, say Like this (I added a ) ? TODO
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#>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?localisation_administrativeLabel ?airport ?airportLabel (SAMPLE(?coord) AS ?coord) ?ICAO ?IATA (SAMPLE(?Local_Code) AS ?Local_Code) WHERE {
?airport (wdt:P31/wdt:P279*) wd:Q62447.
?airport wdt:P17 wd:Q30.
MINUS { ?airport wdt:P576 _:b2. }
MINUS { ?airport wdt:P582 _:b3. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q1311670. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q7373622. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q2265915. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q44665966. }
MINUS { ?airport (wdt:P31/wdt:P279*) wd:Q782667. }
MINUS { ?airport rdf:type wdno:P17. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,[AUTO_LANGUAGE]". }
OPTIONAL { ?airport wdt:P625 ?coord. }
OPTIONAL { ?airport wdt:P239 ?ICAO. }
OPTIONAL { ?airport wdt:P238 ?IATA. }
OPTIONAL { ?airport wdt:P240 ?Local_Code. }
OPTIONAL {
?airport wdt:P131* ?localisation_administrative.
?localisation_administrative wdt:P31 ?type.
?type wdt:P279* wd:Q35657.
}
}
GROUP BY ?airport ?airportLabel ?ICAO ?IATA ?localisation_administrative ?localisation_administrativeLabel
ORDER BY ?coord
Query found at
- https://www.wikidata.org/wiki/User:Bouzinac/D%C3%A9doublonnages
- https://www.wikidata.org/wiki/Wikidata:Request_a_query/Archive/2019/02