query-2317b4e6b6f16b4c4282637ed38abf1f

rq turtle/ttl

title: List of all stage winners by country SELECT ?country ?countryLabel (COUNT(*) as ?count) WHERE { ?item wdt:P361 wd:Q61778309; rdfs:label ?itemLabel. FILTER((LANG(?itemLabel)) = "[AUTO_LANGUAGE]") ?item wdt:P585 ?date. ?item p:P1346 ?statement. ?statement ps:P1346 ?winner. ?statement pq:P642 wd:Q20882747 . ?winner rdfs:label ?winnerLabel. FILTER((LANG(?winnerLabel)) = "[AUTO_LANGUAGE]" ) ?winner wdt:P27 ?country. ?country rdfs:label ?countryLabel. FILTER((LANG(?countryLabel)) = "[AUTO_LANGUAGE]" )

} GROUP BY ?country ?countryLabel ORDER BY DESC(?count)

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 by country
SELECT  ?country ?countryLabel (COUNT(*) as ?count) WHERE {
  ?item wdt:P361 wd:Q61778309;
    rdfs:label ?itemLabel.
  FILTER((LANG(?itemLabel)) = "[AUTO_LANGUAGE]")
  ?item wdt:P585 ?date. 
  ?item p:P1346 ?statement.
  ?statement ps:P1346 ?winner.
  ?statement pq:P642 wd:Q20882747 .
  ?winner rdfs:label ?winnerLabel.
  FILTER((LANG(?winnerLabel)) = "[AUTO_LANGUAGE]" )
  ?winner wdt:P27 ?country.
  ?country rdfs:label ?countryLabel.
  FILTER((LANG(?countryLabel)) = "[AUTO_LANGUAGE]" )

}
GROUP BY ?country ?countryLabel
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?count") v9("?country"):::projected v2("?countryLabel"):::projected v6("?date") v5("?item") v4("?itemLabel") v7("?statement") v8("?winner") v3("?winnerLabel") c3(["wd:Q61778309"]):::iri c9(["wd:Q20882747"]):::iri f0[["?countryLabel = '#91;AUTO_LANGUAGE#93;'"]] f0 --> v2 f1[["?winnerLabel = '#91;AUTO_LANGUAGE#93;'"]] f1 --> v3 f2[["?itemLabel = '#91;AUTO_LANGUAGE#93;'"]] f2 --> v4 v5 --"p:direct/P361"--> c3 v5 --"rdfs:label"--> v4 v5 --"p:direct/P585"--> v6 v5 --"p:P1346"--> v7 v7 --"p:statement/P1346"--> v8 v7 --"p:qualifier/P642"--> c9 v8 --"rdfs:label"--> v3 v8 --"p:direct/P27"--> v9 v9 --"rdfs:label"--> v2 bind4[/"count(*)"/] bind4 --as--o v10