query-bc14bd24c18b7557ee1c8f77b1ffbf5d
15:29, 8 September 2016 (UTC)) talk (SycedHow to do? Thank you! 16:57, 8 September 2016 (UTC) MolarusIĀ“m not sure if that is the solution. At least I have found the information, that "subqueries are evaluated from the innermost first, to the outermost". Therefore this code might do it. --
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?image Where {
SELECT DISTINCT ?item ?image WHERE {
?item wdt:P131*/wdt:P17 wd:Q183.
?item wdt:P137 wd:Q145.
OPTIONAL {?item wdt:P18 ?image }
}
} Limit 1
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?image"):::projected
v1("?item")
a1((" "))
c3(["wd:Q183"]):::iri
c5(["wd:Q145"]):::iri
v1 --"wdt:P131"--> a1
a1 --"wdt:P17"--> c3
v1 --"wdt:P137"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P18".-> v2
end