query-1b045e1f4202afb52075952a857b1de6

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 bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?date ?terminal
WHERE 
{
  ?item wdt:P361* ?stage.      # part of
  ?stage wdt:P31 wd:Q33881.    # Tour de France
  {?item wdt:P1427 wd:Q12193.} # starts in Brest
  UNION                        # and or
  {?item wdt:P1444 wd:Q12193.} # finishes in Brest
  optional {?item wdt:P585 ?date}      # get the date if it exists   
  optional {?item wdt:P1427 ?starts}   # get the start location value
  optional {?item wdt:P1444 ?finishes} # get the end location value
  bind(if(?starts=wd:Q12193,"starts","finishes") as ?terminal) # work out if the race started or ended in Brest
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?date"):::projected v5("?finishes") v1("?item"):::projected v2("?stage") v4("?starts") v6("?terminal"):::projected c9(["bd:serviceParam"]):::iri c3(["wd:Q33881"]):::iri c5(["wd:Q12193"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal v1 --"wdt:P361"--> v2 v2 --"wdt:P31"--> c3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P1444"--> c5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P1427"--> c5 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P585".-> v3 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1427".-> v4 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1444".-> v5 end bind0[/"if(?starts = 'wd:Q12193','starts','finishes')"/] v4 --o bind0 bind0 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end