query-b03e42d06d0efa0e3618526aa3aff912
List humans that are not males or femalesI am trying to list - or event count humans (Q5) that do not have male (Q6581097) or female (Q6581072) gender. This should work, but it times out all the time. Is there a more efficient way to write the query?
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT (COUNT(?human) as ?chuman)
WHERE
{
?human wdt:P31 wd:Q5 .
FILTER ( !EXISTS{ ?human wdt:P21 wd:Q6581072 } && !EXISTS{ ?human wdt:P21 wd:Q6581097 })
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?chuman")
v1("?human"):::projected
c3(["wd:Q6581097"]):::iri
c5(["wd:Q5"]):::iri
c2(["wd:Q6581072"]):::iri
f0[["not not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P21"--> e0c2
e0v1("?human"):::projected
e0c2(["wd:Q6581072"]):::iri
end
f0--EXISTS--> f0e0
subgraph f0e1["Exists Clause"]
e1v1 --"wdt:P21"--> e1c2
e1v1("?human"):::projected
e1c2(["wd:Q6581097"]):::iri
end
f0--EXISTS--> f0e1
f0 --> v1
f0 --> c1
f0 --> c2
f0 --> c3
v1 --"wdt:P21"--> c2
v1 --"wdt:P21"--> c3
v1 --"wdt:P31"--> c5
bind2[/"count(?human)"/]
v1 --o bind2
bind2 --as--o v2