query-a9763e9a5bd62eab8065c0b58c743c52

rq turtle/ttl

No IATA code & must have an ICAO code SELECT distinct ?item ?itemLabel (group_concat(distinct ?typeLabel; separator = ", ") as ?airport_type) (group_concat(distinct ?countryLabel; separator = ", ") as ?countryL) ?iata ?icao WHERE { ?item wdt:P31/wdt:P279 wd:Q1248784. # ?item must be an instance of an airport, or an instance that is a subclass of an airport ?item wdt:P31 ?type. #get the type ?type rdfs:label ?typeLabel. filter(lang(?typeLabel)="en") #get its label in EN optional {?item wdt:P17 ?country . # ?item may have a country filter not exists {?country pq:P582 [].} # ?country that still exists ?country rdfs:label ?countryLabel. filter(lang(?countryLabel)="en")} #get the country label in EN
filter not exists {?item wdt:P238 ?iata .} # there is no IATA value ?item p:P239 ?node2. # ?item must have a P239 property ?node2 ps:P239 ?icao . # which has an ICAO value
filter not exists {?node2 pq:P582 [].} # and the value has no P582 end time
minus {?item wdt:P31/wdt:P279
wd:Q695850.} # exclude items having instances that are military airports & subclasses thereof minus {?item wdt:P31/wdt:P279 wd:Q695850.} # exclude military airports minus {?item wdt:P31/wdt:P279 wd:Q1311670.} # exclude railways stations minus {?item wdt:P31/wdt:P279 wd:Q7373622.} # exclude Royal Air Force minus {?item wdt:P31/wdt:P279 wd:Q502074.} # exclude héliports minus {?item wdt:P576 ?date} # exclude destructed airports minus {?item wdt:P31/wdt:P279* wd:Q44665966.} # exclude airports being build minus {?item wdt:P576 [].} # remove items with P576 (dissolved, abolished or demolished) as a main property minus {?item wdt:P582 [].} # remove items with P582 (end date) as a main property SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values } group by ?item ?itemLabel ?iata ?icao order by ?itemLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# No IATA code & must have an ICAO code
  SELECT distinct ?item ?itemLabel (group_concat(distinct ?typeLabel; separator = ", ") as ?airport_type) (group_concat(distinct ?countryLabel; separator = ", ") as ?countryL) ?iata ?icao WHERE {
  ?item wdt:P31/wdt:P279* wd:Q1248784.                     # ?item must be an instance of an airport, or an instance that is a subclass of an airport
  ?item wdt:P31 ?type.                                     #get the type
  ?type rdfs:label ?typeLabel. filter(lang(?typeLabel)="en")  #get its label in EN
  optional {?item wdt:P17 ?country .                       # ?item may have a country 
           filter not exists {?country pq:P582 [].}        # ?country that still exists
           ?country rdfs:label ?countryLabel. filter(lang(?countryLabel)="en")}       #get the country label in EN             
  filter not exists {?item wdt:P238 ?iata .}               # there is no IATA value
  ?item p:P239 ?node2.                           # ?item must have a P239 property
  ?node2 ps:P239 ?icao .                         # which has an ICAO value  
  filter not exists {?node2 pq:P582 [].}         # and the value has no P582 end time  
  minus {?item wdt:P31/wdt:P279* wd:Q695850.}              # exclude items having instances that are military airports & subclasses thereof
  minus {?item wdt:P31/wdt:P279* wd:Q695850.}              # exclude military airports
  minus {?item wdt:P31/wdt:P279* wd:Q1311670.}             # exclude railways stations
  minus {?item wdt:P31/wdt:P279* wd:Q7373622.}             # exclude Royal Air Force
  minus {?item wdt:P31/wdt:P279* wd:Q502074.}              # exclude héliports
  minus {?item wdt:P576 ?date}                             # exclude destructed airports
  minus {?item wdt:P31/wdt:P279* wd:Q44665966.}            # exclude  airports being build
  minus {?item wdt:P576 [].}                               # remove items with P576 (dissolved, abolished or demolished) as a main property
  minus {?item wdt:P582 [].}                               # remove items with P582 (end date) as a main property
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
} group by ?item ?itemLabel ?iata ?icao order by ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v11("?airport_type") v6("?country") v12("?countryL") v7("?countryLabel"):::projected v10("?date") v4("?iata"):::projected v9("?icao"):::projected v3("?item"):::projected v1("?itemLabel"):::projected v2("?node2") v8("?type") v5("?typeLabel"):::projected a2((" ")) a1((" ")) a10((" ")) a11((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) a9((" ")) c13(["wd:Q7373622"]):::iri c6(["wd:Q1248784"]):::iri c19(["bd:serviceParam"]):::iri c12(["wd:Q1311670"]):::iri c11(["wd:Q695850"]):::iri c16(["wd:Q44665966"]):::iri c21(["#91;AUTO_LANGUAGE#93;,en"]):::literal c14(["wd:Q502074"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0a1 e0v1("?node2"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> a1 v2 --"p:qualifier/P582"--> a1 f1[["not "]] subgraph f1e1["Exists Clause"] e1v1 --"p:direct/P238"--> e1v2 e1v2("?iata"):::projected e1v1("?item"):::projected end f1--EXISTS--> f1e1 f1 --> v3 f1 --> c2 f1 --> v4 v3 --"p:direct/P238"--> v4 f2[["?typeLabel = 'en'"]] f2 --> v5 v3 --"p:direct/P31"--> a3 a3 --"p:direct/P279"--> c6 v3 --"p:direct/P31"--> v8 v8 --"rdfs:label"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P17".-> v6 v6 --"rdfs:label"--> v7 end v3 --"p:P239"--> v2 v2 --"p:statement/P239"--> v9 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> a4 a4 --"p:direct/P279"--> c11 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> a5 a5 --"p:direct/P279"--> c11 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> a6 a6 --"p:direct/P279"--> c12 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> a7 a7 --"p:direct/P279"--> c13 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> a8 a8 --"p:direct/P279"--> c14 end subgraph minus8["MINUS"] style minus8 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P576"--> v10 end subgraph minus9["MINUS"] style minus9 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P31"--> a9 a9 --"p:direct/P279"--> c16 end subgraph minus10["MINUS"] style minus10 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P576"--> a10 end subgraph minus11["MINUS"] style minus11 stroke-width:6px,fill:pink,stroke:red; v3 --"p:direct/P582"--> a11 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c19 --"wikibase:language"--> c21 end bind14[/"?typeLabel"/] v5 --o bind14 bind14 --as--o v11 bind15[/"?countryLabel"/] v7 --o bind15 bind15 --as--o v12