query-1134a2f42cbab6d72fa51dbbf5c49693
How to retrieve the city of a building with sparql?Hello, For my first SPARQL request, I tried to retrieve some information about the event "journées européennes des amateurs de nœuds" (Q112064134). This item groups each session in other items (since 2001 to 2023). The result is correct, but I would like to improve it a city column.
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?session ?label_fr ?location ?city ?start ?end
WHERE {
?item wdt:P393 ?session .
?item wdt:P31 wd:Q112064134 .
?item rdfs:label ?label_fr filter(lang(?label_fr) = "fr") .
?item wdt:P276 ?site .
OPTIONAL { ?site rdfs:label ?location filter(lang(?location) = "fr") }
?item wdt:P580 ?start .
?item wdt:P582 ?end .
}
ORDER BY ?label_fr
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?end"):::projected
v3("?item")
v1("?label_fr"):::projected
v2("?location"):::projected
v4("?session"):::projected
v5("?site")
v6("?start"):::projected
c4(["wd:Q112064134"]):::iri
f0[["?label_fr = 'fr'"]]
f0 --> v1
v3 --"wdt:P393"--> v4
v3 --"wdt:P31"--> c4
v3 --"rdfs:label"--> v1
v3 --"wdt:P276"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."rdfs:label".-> v2
end
v3 --"wdt:P580"--> v6
v3 --"wdt:P582"--> v7