query-bf8b66cf04b5f2702bb2ffd006100cdb

rq turtle/ttl

Current sovereign states with capitals by continent (in German)

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#>
SELECT ?country ?continentName ?countryName (GROUP_CONCAT(DISTINCT(?capitalName);separator=", ") AS ?capitals) WHERE {
  ?country wdt:P31 wd:Q3624078 . ?country rdfs:label ?countryName . FILTER(lang(?countryName) = "de")
  FILTER NOT EXISTS {?country wdt:P31 wd:Q3024240} .
  FILTER NOT EXISTS {?country wdt:P31 wd:Q1145276} .
  OPTIONAL{?country wdt:P36 ?capital . ?capital rdfs:label ?capitalName . FILTER(lang(?capitalName) = "de")}
  ?country wdt:P30 ?continent . ?continent rdfs:label ?continentName . FILTER(lang(?continentName) = "de")
}
GROUP BY ?country ?countryName ?continent ?continentName
ORDER BY ?continentName ?countryName

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?capital") v4("?capitalName"):::projected v7("?capitals") v6("?continent") v1("?continentName"):::projected v3("?country"):::projected v2("?countryName"):::projected c4(["wd:Q3024240"]):::iri c5(["wd:Q3624078"]):::iri c3(["wd:Q1145276"]):::iri f0[["?continentName = 'de'"]] f0 --> v1 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"wdt:P31"--> e0c2 e0v1("?country"):::projected e0c2(["wd:Q1145276"]):::iri end f1--EXISTS--> f1e0 f1 --> v3 f1 --> c2 f1 --> c3 v3 --"wdt:P31"--> c3 f2[["not "]] subgraph f2e1["Exists Clause"] e1v1 --"wdt:P31"--> e1c2 e1v1("?country"):::projected e1c2(["wd:Q3024240"]):::iri end f2--EXISTS--> f2e1 f2 --> v3 f2 --> c2 f2 --> c4 v3 --"wdt:P31"--> c4 f3[["?countryName = 'de'"]] f3 --> v2 v3 --"wdt:P31"--> c5 v3 --"rdfs:label"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P36".-> v5 v5 --"rdfs:label"--> v4 end v3 --"wdt:P30"--> v6 v6 --"rdfs:label"--> v1 bind5[/"?capitalName"/] v4 --o bind5 bind5 --as--o v7