query-0e99ca3d4edecc33bbd8e5ce7ff9565a

rq turtle/ttl

QA - ambassador lacks either of gender or occupation=diplomat

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select distinct ?person ?personLabel ?lacking_gender ?lacking_occ




where
{
  { { select ?person  ?lacking_gender where
{
   { select ?person where
{
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . # find positions they held
} }  filter not exists {?person wdt:P21 [].}      #gender
  bind("1" as ?lacking_gender)
} }} union { { select ?person ?lacking_occ where
{
   { select ?person where
{
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . # find positions they held
} }  filter not exists {?person wdt:P106 wd:Q193391.}  #occupation
  bind("1" as ?lacking_occ)
} }}
  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; v4("?lacking_gender"):::projected v5("?lacking_occ"):::projected v1("?person"):::projected v2("?position") v3("?positionStatement") a1((" ")) c3(["wd:Q18115939"]):::iri c8(["wd:Q193391"]):::iri c10(["bd:serviceParam"]):::iri c4(["wd:Q56760832"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:direct/P106"--> e0c2 e0v1("?person"):::projected e0c2(["wd:Q193391"]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c7 f0 --> c8 v1 --"p:direct/P106"--> c8 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c4 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c3 end union1r <== or ==> union1l end v1 --"p:P39"--> v3 v3 --"p:statement/P39"--> v2 bind1[/"'1'"/] bind1 --as--o v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f2[["not "]] subgraph f2e1["Exists Clause"] e1v1 --"p:direct/P21"--> e1a1 e1v1("?person"):::projected e1a1((" ")):::projected end f2--EXISTS--> f2e1 f2 --> v1 f2 --> c1 f2 --> a1 v1 --"p:direct/P21"--> a1 subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c4 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> c3 end union2r <== or ==> union2l end v1 --"p:P39"--> v3 v3 --"p:statement/P39"--> v2 bind3[/"'1'"/] bind3 --as--o v4 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end