query-898819748410a0deb6919636150d0c96
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT (COUNT(?item) AS ?number_of_Q101352)
(SUM(?n1705) AS ?has_P1705)
(SUM(?n2440) AS ?has_P2440)
(SUM(?both) AS ?has_both)
(SUM(?neither) AS ?has_neither)
{
?item wdt:P31 wd:Q101352 .
OPTIONAL { ?item wdt:P1705 ?p1705 } BIND(IF(BOUND(?p1705),1,0) AS ?n1705)
OPTIONAL { ?item wdt:P2440 ?p2440 } BIND(IF(BOUND(?p2440),1,0) AS ?n2440)
BIND(IF(BOUND(?p1705) && BOUND(?p2440),1,0) AS ?both)
BIND(IF(!BOUND(?p1705) && !BOUND(?p2440),1,0) AS ?neither)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?both"):::projected
v9("?has_P1705")
v10("?has_P2440")
v11("?has_both")
v12("?has_neither")
v1("?item"):::projected
v3("?n1705"):::projected
v5("?n2440"):::projected
v7("?neither"):::projected
v8("?number_of_Q101352")
v2("?p1705")
v4("?p2440")
c2(["wd:Q101352"]):::iri
v1 --"wdt:P31"--> c2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P1705".-> v2
end
bind0[/"if(bound(?p1705),'1^^xsd:integer','0^^xsd:integer')"/]
v2 --o bind0
bind0 --as--o v3
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P2440".-> v4
end
bind1[/"if(bound(?p2440),'1^^xsd:integer','0^^xsd:integer')"/]
v4 --o bind1
bind1 --as--o v5
bind2[/"if(bound(?p1705)bound(?p2440),'1^^xsd:integer','0^^xsd:integer')"/]
v2 --o bind2
v4 --o bind2
bind2 --as--o v6
bind3[/"if(not bound(?p1705)not bound(?p2440),'1^^xsd:integer','0^^xsd:integer')"/]
v2 --o bind3
v4 --o bind3
bind3 --as--o v7
bind9[/"count(?item)"/]
v1 --o bind9
bind9 --as--o v8
bind10[/"sum(?n1705)"/]
v3 --o bind10
bind10 --as--o v9
bind11[/"sum(?n2440)"/]
v5 --o bind11
bind11 --as--o v10
bind12[/"sum(?both)"/]
v6 --o bind12
bind12 --as--o v11
bind13[/"sum(?neither)"/]
v7 --o bind13
bind13 --as--o v12