query-6ab8dafe501efebd16b0dae4b38bb202

rq turtle/ttl

Countries

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 
  ?municipalities
  (CONCAT("#country/", SUBSTR(STR(?country), 32), "/municipality") AS ?municipalitiesUrl)

  ?country ?countryLabel
  (CONCAT("#country/", SUBSTR(STR(?country), 32)) AS ?countryUrl)
  ?countryDescription
WHERE {
   {
  SELECT 
    (COUNT(?municipality) AS ?municipalities)
    ?country
  WHERE {
    ?municipality wdt:P31 / wdt:P279* wd:Q15284 ;
                  wdt:P17 ?country
  }
  GROUP BY ?country
}  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?municipalities)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?country"):::projected v5("?countryUrl") v4("?municipalities"):::projected v4("?municipalitiesUrl") v2("?municipality") a1((" ")) c6(["bd:serviceParam"]):::iri c3(["wd:Q15284"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v2 --"wdt:P17"--> v3 bind1[/"count(?municipality)"/] v2 --o bind1 bind1 --as--o v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end bind2[/"concat('#country/',substring(str(?country),'32^^xsd:integer'),'/municipality')"/] v3 --o bind2 bind2 --as--o v4 bind3[/"concat('#country/',substring(str(?country),'32^^xsd:integer'))"/] v3 --o bind3 bind3 --as--o v5