query-be56d2d8cd3f3ac171bc102ac6bf9247

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 bd: <http://www.bigdata.com/rdf#>
SELECT ?cityLabel ?countryLabel (MAX(?pop) AS ?population) ?namedLabel (GROUP_CONCAT(distinct ?officeLabel; SEPARATOR=", ") AS ?offices)
WHERE
{
    ?city wdt:P31/wdt:P279* wd:Q515 .
    ?city wdt:P138 ?named .
    ?city wdt:P1082 ?pop .
    ?city wdt:P17 ?country .
    ?named wdt:P39 ?office .
    ?office wdt:P31/wdt:P279* wd:Q294414.
    MINUS{ ?office wdt:P31/wdt:P279* wd:Q112806846. }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}

}
GROUP BY ?cityLabel ?countryLabel ?namedLabel
ORDER BY DESC(?population)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?city") v5("?country") v3("?named") v6("?office") v7("?officeLabel"):::projected v8("?offices") v4("?pop"):::projected v8("?population") a1((" ")) a2((" ")) a3((" ")) c13(["en"]):::literal c11(["bd:serviceParam"]):::iri c3(["wd:Q515"]):::iri c8(["wd:Q294414"]):::iri c9(["wd:Q112806846"]):::iri v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v2 --"wdt:P138"--> v3 v2 --"wdt:P1082"--> v4 v2 --"wdt:P17"--> v5 v3 --"wdt:P39"--> v6 v6 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c8 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v6 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end bind3[/"max(?pop)"/] v4 --o bind3 bind3 --as--o v8 bind4[/"?officeLabel"/] v7 --o bind4 bind4 --as--o v8