query-ad56c45c11e9f30d56e3daecfaaad402
TODO
Use at
- https://query.wikidata.org/sparql
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:Q1248784. # item must be an instance of an airport, 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
?item wdt:P17 wd:Q142 . # ?item has country = France
?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((" "))
c13([https://en.wikipedia.org/]):::iri
c4(["wd:Q1248784"]):::iri
c15(["bd:serviceParam"]):::iri
c17(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c10(["wd:Q142"]):::iri
v3 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c4
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
v3 --"wdt:P17"--> c10
v7 --"schema:about"--> v3
v7 --"schema:isPartOf"--> c13
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
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