query-a3de22bf07078902dc3a782e552252c6
causes a Server error and this one works
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 bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":["?geo", "?layer"]}
SELECT DISTINCT ?geo ?xLabel (SAMPLE(?x) AS ?x) (SAMPLE(?population) AS ?population) (SAMPLE(?layer) AS ?layer) WHERE {
?x wdt:P31/wdt:P279* wd:Q6256 ;
# wdt:P30 wd:Q46 ;
wdt:P3896 ?geo ;
wdt:P1082 ?population.
BIND(
IF(?population < 100000, "<100,000",
IF(?population < 500000, "100,000-500,000",
IF(?population < 1000000, "500,000-1M",
IF(?population < 2000000, "1M-2M",
IF(?population < 5000000, "2M-5M",
IF(?population < 10000000, "5M-10M",
IF(?population < 20000000, "10M-20M",
IF(?population < 40000000, "20M-40M",
IF(?population < 60000000, "40M-60M",
IF(?population < 80000000, "60M-80M",
IF(?population < 100000000, "80M-100M",
IF(?population < 200000000, "100M-200M",
IF(?population < 500000000, "200M-500M",
IF(?population < 1000000000, "500M-1B",
IF(?population > 1000000000, "1B+",
"")))))))))))))))
AS ?layer).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?geo ?xLabel
ORDER BY ?population
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?geo"):::projected
v5("?layer"):::projected
v5("?population"):::projected
v5("?x"):::projected
a1((" "))
c7(["bd:serviceParam"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c3(["wd:Q6256"]):::iri
v5 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
v5 --"wdt:P3896"--> v3
v5 --"wdt:P1082"--> v5
bind0[/"if(?population < '100000^^xsd:integer','<100,000',if(?population < '500000^^xsd:integer','100,000-500,000',if(?population < '1000000^^xsd:integer','500,000-1M',if(?population < '2000000^^xsd:integer','1M-2M',if(?population < '5000000^^xsd:integer','2M-5M',if(?population < '10000000^^xsd:integer','5M-10M',if(?population < '20000000^^xsd:integer','10M-20M',if(?population < '40000000^^xsd:integer','20M-40M',if(?population < '60000000^^xsd:integer','40M-60M',if(?population < '80000000^^xsd:integer','60M-80M',if(?population < '100000000^^xsd:integer','80M-100M',if(?population < '200000000^^xsd:integer','100M-200M',if(?population < '500000000^^xsd:integer','200M-500M',if(?population < '1000000000^^xsd:integer','500M-1B',if(?population > '1000000000^^xsd:integer','1B+','')))))))))))))))"/]
v5 --o bind0
bind0 --as--o v5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end
bind4[/"sample(?x)"/]
v5 --o bind4
bind4 --as--o v5
bind5[/"sample(?population)"/]
v5 --o bind5
bind5 --as--o v5
bind6[/"sample(?layer)"/]
v5 --o bind6
bind6 --as--o v5