query-a4c066ef8424820a84c0f76fa85a789a

rq turtle/ttl

MAINTAINCE QUERY: Return only values without country assigned

instances_of=airport (Q1248784); NOT EXISTS P17 ?country

SELECT DISTINCT ?item ?itemLabel ?countryLabel ?icao ?iata ?geo ?official_website WHERE { VALUES ?instances_of { wd:Q1248784 } { ?item (p:P31/ps:P31/(wdt:P279*)) ?instances_of. } OPTIONAL { ?item wdt:P17 ?country. } OPTIONAL { ?item wdt:P239 ?icao. } OPTIONAL { ?item wdt:P238 ?iata. } OPTIONAL { ?item wdt:P625 ?geo. } OPTIONAL { ?item wdt:P856 ?official_website. } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru,es,ja,zh,ar". } FILTER(NOT EXISTS { ?item wdt:P17 ?val. }) } ORDER BY (?countryLabel)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# MAINTAINCE QUERY: Return only values without country assigned
# instances_of=airport (Q1248784); NOT EXISTS P17 ?country
SELECT DISTINCT ?item ?itemLabel ?countryLabel ?icao ?iata ?geo ?official_website WHERE {
  VALUES ?instances_of {
    wd:Q1248784
  }
  { ?item (p:P31/ps:P31/(wdt:P279*)) ?instances_of. }
  OPTIONAL { ?item wdt:P17 ?country. }
  OPTIONAL { ?item wdt:P239 ?icao. }
  OPTIONAL { ?item wdt:P238 ?iata. }
  OPTIONAL { ?item wdt:P625 ?geo. }
  OPTIONAL { ?item wdt:P856 ?official_website. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,ru,es,ja,zh,ar". }
  FILTER(NOT EXISTS { ?item wdt:P17 ?val. })
}
ORDER BY (?countryLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?country") v1("?countryLabel"):::projected v8("?geo"):::projected v7("?iata"):::projected v6("?icao"):::projected v4("?instances_of") v2("?item"):::projected v9("?official_website"):::projected v3("?val") a1((" ")) a2((" ")) c12(["#91;AUTO_LANGUAGE#93;,en,de,fr,ru,es,ja,zh,ar"]):::literal c10(["bd:serviceParam"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:direct/P17"--> e0v2 e0v1("?item"):::projected e0v2("?val"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 v2 --"p:direct/P17"--> v3 bind1[/VALUES ?instances_of/] bind1-->v4 bind10(["wd:Q1248784"]) bind10 --> bind1 v2 --"p:P31"--> a1 a1 --"p:statement/P31"--> a2 a2 --"p:direct/P279"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P17".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P239".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P238".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P625".-> v8 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P856".-> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end