query-722a514e2200f18b89da28d8c026db23

rq turtle/ttl

title:Byzantinists by citizenship and gender SELECT ?nLabel (COUNT(?male_) AS ?male) (COUNT(?female_) AS ?female) (COUNT(?other_) AS ?other) WHERE { { ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n . ?item wdt:P21 wd:Q6581097 . bind ("m" as ?male_) } UNION { ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n . ?item wdt:P21 wd:Q6581072 . bind ("f" as ?female_) } UNION { ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n . ?item wdt:P21 ?g . filter (?g not in (wd:Q6581097, wd:Q6581072)) bind ("o" as ?other_) } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } } GROUP BY ?nLabel ORDER BY ?nLabel

Use at

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#>
#title:Byzantinists by citizenship and gender
SELECT ?nLabel (COUNT(?male_) AS ?male) (COUNT(?female_) AS ?female) (COUNT(?other_) AS ?other) 
WHERE {
  {
    ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n .
    ?item wdt:P21 wd:Q6581097 .
    bind ("m" as ?male_)
  } UNION {
    ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n .
    ?item wdt:P21 wd:Q6581072 .
    bind ("f" as ?female_)
  } UNION {
    ?item wdt:P106 wd:Q26132815 ; wdt:P27 ?n .
    ?item wdt:P21 ?g . filter (?g not in (wd:Q6581097, wd:Q6581072))
    bind ("o" as ?other_)
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}
GROUP BY ?nLabel
ORDER BY ?nLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?female") v5("?female_"):::projected v6("?g") v2("?item") v8("?male") v4("?male_"):::projected v3("?n") v1("?nLabel"):::projected v10("?other") v7("?other_"):::projected c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;"]):::literal c2(["wd:Q26132815"]):::iri c5(["wd:Q6581097"]):::iri c6(["wd:Q6581072"]):::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; f0[["?g != 'wd:Q6581097'?g != 'wd:Q6581072'"]] f0 --> v6 v2 --"wdt:P106"--> c2 v2 --"wdt:P27"--> v3 v2 --"wdt:P21"--> v6 bind1[/"'o'"/] bind1 --as--o v7 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P106"--> c2 v2 --"wdt:P27"--> v3 v2 --"wdt:P21"--> c6 bind2[/"'f'"/] bind2 --as--o v5 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P106"--> c2 v2 --"wdt:P27"--> v3 v2 --"wdt:P21"--> c5 bind3[/"'m'"/] bind3 --as--o v4 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind7[/"count(?male_)"/] v4 --o bind7 bind7 --as--o v8 bind8[/"count(?female_)"/] v5 --o bind8 bind8 --as--o v9 bind9[/"count(?other_)"/] v7 --o bind9 bind9 --as--o v10