query-ce5a745a9e85997a9158e90797e040cd

rq turtle/ttl

Country-level query example

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#>
# instances_of=airport (Q1248784); country=Brazil (Q155);
#defaultView:Map
SELECT DISTINCT ?item ?itemLabel ?itemDescription ?icao ?iata ?geo ?official_website WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q1248784.
      ?item p:P17 ?statement1.
      ?statement1 ps:P17 wd:Q155.  # Change country here
      # MINUS { ?item wdt:P31 wd:Q861951. }
    }
  }

  OPTIONAL { ?item wdt:P239 ?icao. }
  OPTIONAL { ?item wdt:P238 ?iata. }
  OPTIONAL { ?item wdt:P625 ?geo. }
  OPTIONAL { ?item wdt:P856 ?official_website. }
}
ORDER BY  (?icao)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?geo"):::projected v5("?iata"):::projected v1("?icao"):::projected v2("?item"):::projected v7("?official_website"):::projected v3("?statement0") v4("?statement1") a1((" ")) c2(["bd:serviceParam"]):::iri c8(["wd:Q1248784"]):::iri c4(["#91;AUTO_LANGUAGE#93;"]):::literal c11(["wd:Q155"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end v2 --"p:P31"--> v3 v3 --"p:statement/P31"--> a1 a1 --"p:direct/P279"--> c8 v2 --"p:P17"--> v4 v4 --"p:statement/P17"--> c11 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P239".-> v1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P238".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P625".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P856".-> v7 end