query-e862255a247845a5e71e2b237f9b4c75

rq turtle/ttl

Ville de Suisse avec leur population et altitude SELECT ?country ?countryLabel ?population ?citypopulation ?altitude ?city ?cityLabel (?citypopulation * ?altitude / ?totalCityPopulation AS ?altw) { ?city wdt:P31 wd:Q515 . ?city wdt:P17 ?country . ?city wdt:P1082 ?citypopulation . ?city wdt:P2044 ?altitude. ?country wdt:P1082 ?population. VALUES ?country {wd:Q39}. SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } { SELECT ?country (SUM(?cityPopulation) AS ?totalCityPopulation) WHERE { ?city wdt:P31 wd:Q515 . ?city wdt:P17 ?country . ?city wdt:P1082 ?cityPopulation . } GROUP BY ?country } }

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#>
#Ville de Suisse avec leur population et altitude
SELECT ?country ?countryLabel ?population ?citypopulation ?altitude ?city ?cityLabel (?citypopulation * ?altitude / ?totalCityPopulation AS ?altw) {
  ?city wdt:P31 wd:Q515 .
      ?city wdt:P17 ?country .
      ?city wdt:P1082 ?citypopulation .
      ?city wdt:P2044 ?altitude.
      ?country wdt:P1082 ?population.
      VALUES ?country {wd:Q39}.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
  {
    SELECT ?country (SUM(?cityPopulation) AS ?totalCityPopulation) WHERE {
      ?city wdt:P31 wd:Q515 .
      ?city wdt:P17 ?country .
      ?city wdt:P1082 ?cityPopulation .
    } GROUP BY ?country
  }
  }

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?altitude"):::projected v8("?altw") v1("?city"):::projected v6("?cityPopulation") v3("?citypopulation"):::projected v6("?country"):::projected v5("?population"):::projected v7("?totalCityPopulation"):::projected c7(["bd:serviceParam"]):::iri c2(["wd:Q515"]):::iri c9(["en"]):::literal v1 --"wdt:P31"--> c2 v1 --"wdt:P17"--> v6 v1 --"wdt:P1082"--> v3 v1 --"wdt:P2044"--> v4 v6 --"wdt:P1082"--> v5 bind0[/VALUES ?country/] bind0-->v6 bind00(["wd:Q39"]) bind00 --> bind0 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end v1 --"wdt:P31"--> c2 v1 --"wdt:P17"--> v6 v1 --"wdt:P1082"--> v6 bind2[/"sum(?cityPopulation)"/] v6 --o bind2 bind2 --as--o v7 bind3[/"?citypopulation * ?altitude / ?totalCityPopulation"/] v3 --o bind3 v4 --o bind3 v7 --o bind3 bind3 --as--o v8