query-a471bacf07a3063d20f11726172e4dde
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
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".
?office rdfs:label ?officeLabel.
?city rdfs:label ?cityLabel.
?country rdfs:label ?countryLabel.
?named rdfs:label ?namedLabel.}
}
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")
v8("?cityLabel"):::projected
v5("?country")
v9("?countryLabel"):::projected
v3("?named")
v10("?namedLabel"):::projected
v6("?office")
v7("?officeLabel"):::projected
v11("?offices")
v4("?pop"):::projected
v11("?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
v6 --"rdfs:label"--> v7
v2 --"rdfs:label"--> v8
v5 --"rdfs:label"--> v9
v3 --"rdfs:label"--> v10
end
bind3[/"max(?pop)"/]
v4 --o bind3
bind3 --as--o v11
bind4[/"?officeLabel"/]
v7 --o bind4
bind4 --as--o v11