query-df6e39581e9d4146ff884267f1cfb6bf

rq turtle/ttl

Biographies at orwiki 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 { ?item wdt:P31 wd:Q5. ?item wdt:P106 ?job. OPTIONAL { ?item wdt:P21 ?sex. } BIND(IF(?sex = wd:Q6581097, 1, 0) as ?male) BIND(IF(?sex = wd:Q6581072, 1, 0) as ?female) ?link schema:about ?item; schema:isPartOf https://or.wikipedia.org/. } GROUP BY ?job ORDER BY DESC(?count) limit 20 } as %i where { include %i SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }

Use at

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#>
# Biographies at orwiki 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 {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P106 ?job.
  OPTIONAL { ?item wdt:P21 ?sex. }
  BIND(IF(?sex = wd:Q6581097, 1, 0) as ?male) 
  BIND(IF(?sex = wd:Q6581072, 1, 0) as ?female)
  ?link schema:about ?item;
        schema:isPartOf <https://or.wikipedia.org/>.
} 
  GROUP BY ?job
  ORDER BY DESC(?count)
  limit 20
}SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],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") v2("?item") v3("?job"):::projected v7("?link") v8("?m"):::projected v5("?male") v4("?sex") c9(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7([https://or.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