query-a0e0ce02de071979384cfd83ab82b537

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?sitelink (group_concat(distinct ?serve;separator=", ") as ?serves) (group_concat(distinct ?iata_c;separator=", ") as ?iata) (group_concat(distinct ?icao_c;separator=", ") as ?icao)
WHERE {
  ?item wdt:P31/wdt:P279* wd:Q62447.                     # item must be an instance of an airport, or of a subclass of an airport
  ?item wdt:P31/wdt:P279* wd:Q170584.                      # item must also be an instance of a project, or of a subclass of an airport
  optional {?item wdt:P238 ?iata_c .}                      # item may have a P238 (IATA) value
  optional {?item wdt:P239 ?icao_c .}                      # item may have has a P239 (ICAO) value         
  optional {?item wdt:P931 ?place_served .                 # item may have a value for P931  
           ?place_served rdfs:label ?serve.                # and if so, we get the label for the value directly (so group_concat will work)
           filter(lang(?serve)="en")}                      # but we only get the english language label                  
  ?sitelink schema:about ?item;                            # item has a sitelink
            schema:isPartOf <https://en.wikipedia.org/>.   # the sitelink points to en.wikipedia
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . #this bit gets labels for Qid values
} group by ?item ?itemLabel ?sitelink order by ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?iata") v4("?iata_c"):::projected v10("?icao") v5("?icao_c"):::projected v3("?item"):::projected v1("?itemLabel"):::projected v6("?place_served") v2("?serve"):::projected v8("?serves") v7("?sitelink"):::projected a1((" ")) a2((" ")) c4(["wd:Q62447"]):::iri c12([https://en.wikipedia.org/]):::iri c14(["bd:serviceParam"]):::iri c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal c5(["wd:Q170584"]):::iri v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c4 v3 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P238".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P239".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P931".-> v6 v6 --"rdfs:label"--> v2 end v7 --"schema:about"--> v3 v7 --"schema:isPartOf"--> c12 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end bind3[/"?serve"/] v2 --o bind3 bind3 --as--o v8 bind4[/"?iata_c"/] v4 --o bind4 bind4 --as--o v9 bind5[/"?icao_c"/] v5 --o bind5 bind5 --as--o v10