query-7218b52830060e442476c78b2b2ac66b

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?country ?countryLabel ?city ?cityLabel WHERE {
  ?country wdt:P31 wd:Q3624078 . # all sovereign states
  ?city p:P1376 ?statement .     # get their capital
  ?statement ps:P1376 ?country .
  FILTER NOT EXISTS { ?statement pq:P582 [] } # unless it has an end date
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?countryLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?city"):::projected v3("?country"):::projected v1("?countryLabel"):::projected v2("?statement") a1((" ")) c3(["wd:Q3624078"]):::iri c7(["bd:serviceParam"]):::iri c9(["en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0a1 e0v1("?statement"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> a1 v2 --"p:qualifier/P582"--> a1 v3 --"p:direct/P31"--> c3 v4 --"p:P1376"--> v2 v2 --"p:statement/P1376"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end