query-7dd720643738e81164929812f4643aeb
Pivot table for blood types. en:Blood type distribution by countryReference values:
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 ?items
(CONCAT(str(round(10000 * ?o/?items) / 100), "%") as ?O)
(CONCAT(str(round(10000 * ?a/?items) / 100), "%") as ?A)
(CONCAT(str(round(10000 * ?b/?items) / 100), "%") as ?B)
(CONCAT(str(round(10000 * ?ab/?items) / 100), "%") as ?AB) {
{
SELECT ?country (count(?o_items) as ?o) (count(?a_items) as ?a) (count(?b_items) as ?b) (count(?ab_items) as ?ab) (count(?all_items) as ?items) {
{?o_items wdt:P1853 wd:Q19831451 ; wdt:P27 ?country ; wdt:P31 wd:Q5 } UNION
{?a_items wdt:P1853 wd:Q19831453 ; wdt:P27 ?country ; wdt:P31 wd:Q5 } UNION
{?b_items wdt:P1853 wd:Q19831454 ; wdt:P27 ?country ; wdt:P31 wd:Q5 } UNION
{?ab_items wdt:P1853 wd:Q19831455 ; wdt:P27 ?country ; wdt:P31 wd:Q5 } UNION
{?all_items wdt:P1853 [] ; wdt:P27 ?country ; wdt:P31 wd:Q5 }
}
GROUP BY ?country
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(?items)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v13("?A")
v15("?AB")
v14("?B")
v12("?O")
v9("?a"):::projected
v4("?a_items")
v11("?ab"):::projected
v6("?ab_items")
v7("?all_items")
v10("?b"):::projected
v5("?b_items")
v3("?country"):::projected
v12("?items"):::projected
v8("?o"):::projected
v2("?o_items")
a1((" "))
c6(["wd:Q19831453"]):::iri
c2(["wd:Q19831451"]):::iri
c10(["bd:serviceParam"]):::iri
c5(["wd:Q5"]):::iri
c12(["en"]):::literal
c8(["wd:Q19831455"]):::iri
c7(["wd:Q19831454"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
v7 --"wdt:P1853"--> a1
v7 --"wdt:P27"--> v3
v7 --"wdt:P31"--> c5
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P1853"--> c8
v6 --"wdt:P27"--> v3
v6 --"wdt:P31"--> c5
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v5 --"wdt:P1853"--> c7
v5 --"wdt:P27"--> v3
v5 --"wdt:P31"--> c5
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"wdt:P1853"--> c6
v4 --"wdt:P27"--> v3
v4 --"wdt:P31"--> c5
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P1853"--> c2
v2 --"wdt:P27"--> v3
v2 --"wdt:P31"--> c5
end
union0r <== or ==> union0l
end
bind5[/"count(?o_items)"/]
v2 --o bind5
bind5 --as--o v8
bind6[/"count(?a_items)"/]
v4 --o bind6
bind6 --as--o v9
bind7[/"count(?b_items)"/]
v5 --o bind7
bind7 --as--o v10
bind8[/"count(?ab_items)"/]
v6 --o bind8
bind8 --as--o v11
bind9[/"count(?all_items)"/]
v7 --o bind9
bind9 --as--o v12
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
bind10[/"concat(str(numeric-round('10000^^xsd:integer' * ?o / ?items) / '100^^xsd:integer'),'%')"/]
v8 --o bind10
v12 --o bind10
bind10 --as--o v12
bind11[/"concat(str(numeric-round('10000^^xsd:integer' * ?a / ?items) / '100^^xsd:integer'),'%')"/]
v9 --o bind11
v12 --o bind11
bind11 --as--o v13
bind12[/"concat(str(numeric-round('10000^^xsd:integer' * ?b / ?items) / '100^^xsd:integer'),'%')"/]
v10 --o bind12
v12 --o bind12
bind12 --as--o v14
bind13[/"concat(str(numeric-round('10000^^xsd:integer' * ?ab / ?items) / '100^^xsd:integer'),'%')"/]
v11 --o bind13
v12 --o bind13
bind13 --as--o v15