query-7774f9d9c13a3e5ab684a79ff27d2681

rq turtle/ttl

SPARQL query

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?city ?country WHERE {
  ?city wdt:P31/wdt:P279* wd:Q515 ; wdt:P1082 ?population .
  FILTER (?population > 1000000) .
  FILTER NOT EXISTS { ?city wdt:P576 [] } .
  OPTIONAL { ?city wdt:P17 ?country }
} 
ORDER BY DESC(?population)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?city"):::projected v3("?country"):::projected v1("?population") a1((" ")) a2((" ")) c5(["wd:Q515"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P576"--> e0a1 e0v1("?city"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> a1 v2 --"wdt:P576"--> a1 f1[["?population > '1000000^^xsd:integer'"]] f1 --> v1 v2 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c5 v2 --"wdt:P1082"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P17".-> v3 end