query-866f8689026b567fdd2c526af81ec826
.on TwitterOriginally posted
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 ?smallerCityLabel ?smallerPopulation ?mayorLabel ?largerCityLabel ?largerPopulation
WHERE {
{
SELECT DISTINCT ?smallerCity ?smallerPopulation ?mayor ?largerCity ?largerPopulation WHERE {
?smallerCity wdt:P31/wdt:P279* wd:Q515;
wdt:P1082 ?smallerPopulation;
wdt:P6 ?mayor.
?mayor wdt:P31 wd:Q5;
wdt:P735 ?givenName.
?givenName rdfs:label ?label.
?largerCity rdfs:label ?label;
wdt:P31/wdt:P279* wd:Q515;
wdt:P1082 ?largerPopulation.
FILTER(?largerPopulation > ?smallerPopulation)
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?smallerPopulation)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?givenName")
v6("?label")
v7("?largerCity")
v2("?largerPopulation"):::projected
v4("?mayor")
v3("?smallerCity")
v1("?smallerPopulation"):::projected
a1((" "))
a2((" "))
c10(["bd:serviceParam"]):::iri
c3(["wd:Q515"]):::iri
c6(["wd:Q5"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?largerPopulation > ?smallerPopulation"]]
f0 --> v2
f0 --> v1
v3 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
v3 --"wdt:P1082"--> v1
v3 --"wdt:P6"--> v4
v4 --"wdt:P31"--> c6
v4 --"wdt:P735"--> v5
v5 --"rdfs:label"--> v6
v7 --"rdfs:label"--> v6
v7 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c3
v7 --"wdt:P1082"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end