query-59f7b1cb7d1cd9430bdc57e941fbdc11

rq turtle/ttl

Propertiesinstance of (P31)subclass of (P279)sex or gender (P21)population (P1082)head of government (P6)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX q: <http://www.wikidata.org/prop/qualifier/>
PREFIX v: <http://www.wikidata.org/prop/statement/>

SELECT DISTINCT  ?cityLabel ?population (CONCAT("Mayor of ",?cityLabel," : ",?mayorLabel) as ?description)  ?mayorLabel WHERE {
  ?city wdt:P31/wdt:P279* wd:Q515 .
  ?city p:P6 ?statement .
  ?statement v:P6 ?mayor .
  ?mayor wdt:P21 wd:Q6581072 .
  FILTER NOT EXISTS { ?statement q:P582 ?x }

  ?city wdt:P1082 ?population .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
 } ORDER BY DESC(?population) LIMIT 15

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?city") v6("?description") v5("?mayor") v1("?population"):::projected v2("?statement") v3("?x") a1((" ")) c13(["en"]):::literal c8(["wd:Q6581072"]):::iri c11(["bd:serviceParam"]):::iri c4(["wd:Q515"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v1("?statement"):::projected e0v2("?x"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 v2 --"p:qualifier/P582"--> v3 v4 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 v4 --"p:P6"--> v2 v2 --"p:statement/P6"--> v5 v5 --"p:direct/P21"--> c8 v4 --"p:direct/P1082"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end bind1[/"concat('Mayor of ',?cityLabel,' : ',?mayorLabel)"/] null --o bind1 null --o bind1 bind1 --as--o v6