query-8b3c1fc031bc5039a37260dc5162209d
List of religions by countryI am trying to build a query to get a list of all countries and their respective religions and percentage. Example of result I am expecting: 10% Other French 10% Evangelical French 10% Muslim French 10% Catholic French 10% Muslim Jamaica 10% Evangelical Jamaica 10% Catholic Jamaica 10% Muslim Germany 10% Evangelical Germany 10% Catholic Germany Percentage Religion Country With the query below I can get the list of countries but the religions and percentage of people I don't know how to do.
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 ?religion ?religionLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?country wdt:P31 wd:Q3624078.
OPTIONAL { ?country wdt:P140 ?religion. }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?country"):::projected
v2("?religion"):::projected
c2(["bd:serviceParam"]):::iri
c6(["wd:Q3624078"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v1 --"wdt:P31"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P140".-> v2
end