query-e3af8da5e2051915e380f67a08f1ccb6
Count biographies at dawiki by occupation and sex SELECT ?job ?jobLabel ?m ?f ?count with { SELECT ?job (COUNT(?link) AS ?count) (SUM (?male) as ?m) (SUM (?female) as ?f) WHERE { ?person wdt:P31 wd:Q5. ?person wdt:P106 ?job. OPTIONAL { ?person wdt:P21 ?sex. } BIND(IF(?sex = wd:Q6581097, 1, 0) as ?male) BIND(IF(?sex = wd:Q6581072, 1, 0) as ?female) ?link schema:about ?person; schema:isPartOf https://da.wikipedia.org/. } GROUP BY ?job ORDER BY DESC(?count) limit 10 } as %i where { include %i SERVICE wikibase:label { bd:serviceParam wikibase:language "da,en" } }
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 schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Count biographies at dawiki by occupation and sex
SELECT ?job ?jobLabel ?m ?f ?count where
{
{
SELECT ?job (COUNT(?link) AS ?count) (SUM (?male) as ?m) (SUM (?female) as ?f)
WHERE {
?person wdt:P31 wd:Q5.
?person wdt:P106 ?job.
OPTIONAL { ?person wdt:P21 ?sex. }
BIND(IF(?sex = wd:Q6581097, 1, 0) as ?male)
BIND(IF(?sex = wd:Q6581072, 1, 0) as ?female)
?link schema:about ?person;
schema:isPartOf <https://da.wikipedia.org/>.
}
GROUP BY ?job
ORDER BY DESC(?count)
limit 10
} SERVICE wikibase:label { bd:serviceParam wikibase:language "da,en" }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?count"):::projected
v9("?f"):::projected
v6("?female")
v3("?job"):::projected
v7("?link")
v8("?m"):::projected
v5("?male")
v2("?person")
v4("?sex")
c9(["bd:serviceParam"]):::iri
c11(["da,en"]):::literal
c2(["wd:Q5"]):::iri
c7([https://da.wikipedia.org/]):::iri
v2 --"wdt:P31"--> c2
v2 --"wdt:P106"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P21".-> v4
end
bind0[/"if(?sex = 'wd:Q6581097','1^^xsd:integer','0^^xsd:integer')"/]
v4 --o bind0
bind0 --as--o v5
bind1[/"if(?sex = 'wd:Q6581072','1^^xsd:integer','0^^xsd:integer')"/]
v4 --o bind1
bind1 --as--o v6
v7 --"schema:about"--> v2
v7 --"schema:isPartOf"--> c7
bind5[/"count(?link)"/]
v7 --o bind5
bind5 --as--o v8
bind6[/"sum(?male)"/]
v5 --o bind6
bind6 --as--o v8
bind7[/"sum(?female)"/]
v6 --o bind7
bind7 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end