query-9bb2f298aef37215fa5829a6cee6c638

rq turtle/ttl

title: List of all stage winners of the tour de France by country SELECT ?tour ?tourLabel ?startdate ?tournumber ?stage ?stageLabel ?stagenumber ?winner ?winnerLabel ?country ?countryLabel WHERE { ?tour wdt:P31 wd:Q33881; wdt:P580 ?startdate; wdt:P393 ?tournumber; rdfs:label ?tourLabel. FILTER((LANG(?tourLabel)) = "en") ?stage wdt:P361 ?tour; rdfs:label ?stageLabel; wdt:P1545 ?stagenumber; p:P1346 ?statement. FILTER((LANG(?stageLabel)) = "en") ?statement ps:P1346 ?winner; pq:P642 wd:Q20882747. ?winner wdt:P27 ?country;
rdfs:label ?winnerLabel. FILTER((LANG(?winnerLabel)) = "en" ) ?country rdfs:label ?countryLabel. FILTER((LANG(?countryLabel)) = "en" ) } ORDER BY ?tournumber ?stagenumber

Use at

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#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
#title: List of all stage winners of the tour de France by country
SELECT ?tour ?tourLabel ?startdate ?tournumber ?stage ?stageLabel ?stagenumber ?winner ?winnerLabel ?country ?countryLabel WHERE {
  ?tour wdt:P31 wd:Q33881;
        wdt:P580 ?startdate;
        wdt:P393 ?tournumber;
        rdfs:label ?tourLabel.
  FILTER((LANG(?tourLabel)) = "en")
  ?stage wdt:P361 ?tour;
        rdfs:label ?stageLabel;
        wdt:P1545 ?stagenumber;
        p:P1346 ?statement.
  FILTER((LANG(?stageLabel)) = "en")
  ?statement ps:P1346 ?winner;
             pq:P642 wd:Q20882747.
  ?winner wdt:P27 ?country;       
          rdfs:label ?winnerLabel.
  FILTER((LANG(?winnerLabel)) = "en" )
  ?country rdfs:label ?countryLabel.
  FILTER((LANG(?countryLabel)) = "en" )
}
ORDER BY ?tournumber ?stagenumber

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v12("?country"):::projected v3("?countryLabel"):::projected v9("?stage"):::projected v5("?stageLabel"):::projected v2("?stagenumber"):::projected v8("?startdate"):::projected v10("?statement") v7("?tour"):::projected v6("?tourLabel"):::projected v1("?tournumber"):::projected v11("?winner"):::projected v4("?winnerLabel"):::projected c12(["wd:Q20882747"]):::iri c3(["wd:Q33881"]):::iri f0[["?countryLabel = 'en'"]] f0 --> v3 f1[["?winnerLabel = 'en'"]] f1 --> v4 f2[["?stageLabel = 'en'"]] f2 --> v5 f3[["?tourLabel = 'en'"]] f3 --> v6 v7 --"p:direct/P31"--> c3 v7 --"p:direct/P580"--> v8 v7 --"p:direct/P393"--> v1 v7 --"rdfs:label"--> v6 v9 --"p:direct/P361"--> v7 v9 --"rdfs:label"--> v5 v9 --"p:direct/P1545"--> v2 v9 --"p:P1346"--> v10 v10 --"p:statement/P1346"--> v11 v10 --"p:qualifier/P642"--> c12 v11 --"p:direct/P27"--> v12 v11 --"rdfs:label"--> v4 v12 --"rdfs:label"--> v3