query-be66407356ebf16cdb13a43d7d18a039

rq turtle/ttl

Adapting a queryHello Tagishsimon , may I ask your guidance on this

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?code ?item1 ?nature1Label ?item1Label ?date1 ?item2  ?item2Label WHERE {
  ?item1 wdt:P31/wdt:P279* wd:Q1248784. 
  ?item1 wdt:P238 ?code .         #First with code IATA
  ?item1 wdt:P31 ?nature1.        #What kind of airport, aérodrome is it?
  optional { ?code pq:P582 ?date1.}   #For first item, what end date for code AITA
  ?item2 wdt:P238 ?code .         #Second with code IATA
  FILTER ( ?item1 != ?item2 )     #Only différents elements
  minus {?item1 wdt:P31/wdt:P279* wd:Q695850.}      # exclude military airports
  minus {?item1 wdt:P31/wdt:P279* wd:Q1311670.}     # exclude railways stations
  minus {?item1 wdt:P31/wdt:P279* wd:Q7373622.}     # exclude Royal Air Force
  minus {?item2 wdt:P31/wdt:P279* wd:Q695850.}      # exclude military airports
  minus {?item2 wdt:P31/wdt:P279* wd:Q1311670.}     # exclude railways stations
  minus {?item2 wdt:P31/wdt:P279* wd:Q7373622.}     # exclude Royal Air Force
  minus {?item1 wdt:P576 ?date}                     # exclude destructed airports
  minus {?item2 wdt:P576 ?date}                     # exclude destructed airports
  SERVICE wikibase:label { bd:serviceParam wikibase:language  "fr,en". } #récupérer le libellé en français si possible sinon en anglais
  }
ORDER BY ?code #trier les résultats selon le code AITA

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?code"):::projected v6("?date") v5("?date1"):::projected v2("?item1"):::projected v3("?item2"):::projected v4("?nature1") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) c8(["wd:Q7373622"]):::iri c3(["wd:Q1248784"]):::iri c11(["bd:serviceParam"]):::iri c7(["wd:Q1311670"]):::iri c6(["wd:Q695850"]):::iri c13(["fr,en"]):::literal f0[["?item1 != ?item2"]] f0 --> v2 f0 --> v3 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v2 --"wdt:P238"--> v1 v2 --"wdt:P31"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."pq:P582".-> v5 end v3 --"wdt:P238"--> v1 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c6 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c7 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> a4 a4 --"wdt:P279"--> c8 end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a5 a5 --"wdt:P279"--> c6 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a6 a6 --"wdt:P279"--> c7 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P31"--> a7 a7 --"wdt:P279"--> c8 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P576"--> v6 end subgraph minus8["MINUS"] style minus8 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P576"--> v6 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end