query-db202910245ca558646e7f6e84b6f9e3
TODO
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 ?field ?fieldLabel ?number_of_scientists ?of_which_males ?of_which_females ?of_which_others WHERE {
{
SELECT ?field (COUNT(?scientist) AS ?number_of_scientists) (SUM(?males) AS ?of_which_males) (SUM(?females) AS ?of_which_females) (SUM(?others) AS ?of_which_others) {
?scientist wdt:P31 wd:Q5 .
?scientist wdt:P106/wdt:P279* wd:Q901 .
?scientist wdt:P101 ?field .
?scientist wdt:P21 ?gender .
BIND(IF(?gender=wd:Q6581097,1,0) AS ?males)
BIND(IF(?gender=wd:Q6581072,1,0) AS ?females)
BIND(IF(?gender!=wd:Q6581097 && ?gender!=wd:Q6581072,1,0) AS ?others)
FILTER NOT EXISTS { ?scientist wdt:P570 [] }
}
GROUP BY ?field
} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de,fr,es,it,pl,hu,ru,ko,az,hy,nb,fi,be,et,tg,he". }
}
ORDER BY DESC(?number_of_scientists) ?fieldLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?females")
v4("?field"):::projected
v2("?fieldLabel"):::projected
v5("?gender")
v6("?males")
v9("?number_of_scientists"):::projected
v10("?of_which_females"):::projected
v9("?of_which_males"):::projected
v11("?of_which_others"):::projected
v8("?others")
v3("?scientist")
a1((" "))
a2((" "))
c12(["#91;AUTO_LANGUAGE#93;,en,de,fr,es,it,pl,hu,ru,ko,az,hy,nb,fi,be,et,tg,he"]):::literal
c10(["bd:serviceParam"]):::iri
c6(["wd:Q901"]):::iri
c3(["wd:Q5"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P570"--> e0a1
e0v1("?scientist"):::projected
e0a1((" ")):::projected
end
f0--EXISTS--> f0e0
f0 --> v3
f0 --> c1
f0 --> a1
v3 --"wdt:P570"--> a1
v3 --"wdt:P31"--> c3
v3 --"wdt:P106"--> a2
a2 --"wdt:P279"--> c6
v3 --"wdt:P101"--> v4
v3 --"wdt:P21"--> v5
bind1[/"if(?gender = 'wd:Q6581097','1^^xsd:integer','0^^xsd:integer')"/]
v5 --o bind1
bind1 --as--o v6
bind2[/"if(?gender = 'wd:Q6581072','1^^xsd:integer','0^^xsd:integer')"/]
v5 --o bind2
bind2 --as--o v7
bind3[/"if(?gender != 'wd:Q6581097'?gender != 'wd:Q6581072','1^^xsd:integer','0^^xsd:integer')"/]
v5 --o bind3
bind3 --as--o v8
bind8[/"count(?scientist)"/]
v3 --o bind8
bind8 --as--o v9
bind9[/"sum(?males)"/]
v6 --o bind9
bind9 --as--o v9
bind10[/"sum(?females)"/]
v7 --o bind10
bind10 --as--o v10
bind11[/"sum(?others)"/]
v8 --o bind11
bind11 --as--o v11
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end