query-11d3e664810e8b4fe629f2f1ccc208c5

rq turtle/ttl

Retrieve property if availableWithin the following query I want to extract the P580 (start time) property of a statement "heritage designation" (wdt:P1435) is "World Heritage Site" (wd:Q9259) if that property is available and display as ?st. How can I extend the statement within the OPTIONAL clause to accomplish this? As an example: in Q1620833 the start time would be 2002.

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item  ?whsId ?st WHERE {
  ?item wdt:P757 ?whsId.
  OPTIONAL {
    ?item wdt:P1435 wd:Q9259 
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected v2("?whsId"):::projected c5(["bd:serviceParam"]):::iri c7(["en"]):::literal c3(["wd:Q9259"]):::iri v1 --"wdt:P757"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1435".-> c3 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end