query-489456215d2eb87310d421de7754f13c
QueryFor each country : number of persons in Wikidata who have the nationality / population of the country
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#>
SELECT ?country ?countryLabel ?countryCode ?population ?count ?ratio
WHERE
{
?country wdt:P297 ?countryCode .
?country wdt:P1082 ?population .
{
SELECT ?country (COUNT(?person) as ?count)
WHERE
{
?person wdt:P27 ?country.
?country wdt:P31 wd:Q6256 .
}
GROUP BY ?country
}
BIND(?count / ?population * 1000 AS ?ratio).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(?ratio)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?count"):::projected
v2("?country"):::projected
v3("?countryCode"):::projected
v5("?person")
v4("?population"):::projected
v7("?ratio"):::projected
c7(["bd:serviceParam"]):::iri
c9(["en"]):::literal
c5(["wd:Q6256"]):::iri
v2 --"wdt:P297"--> v3
v2 --"wdt:P1082"--> v4
v5 --"wdt:P27"--> v2
v2 --"wdt:P31"--> c5
bind1[/"count(?person)"/]
v5 --o bind1
bind1 --as--o v6
bind2[/"?count / ?population * '1000^^xsd:integer'"/]
v6 --o bind2
v4 --o bind2
bind2 --as--o v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end