query-c497b4dc4eadd60fcd04a89188aab04e
title: count couples with same gender (female) SELECT (count(distinct ?item) as ?count) WHERE { ?item wdt:P26 ?item2 . ?item wdt:P21 wd:Q6581072 . #female ?item2 wdt:P21 wd:Q6581072 . #female #?item wdt:P21 wd:Q6581097 . #male #?item2 wdt:P21 wd:Q6581097 . #male #?item wdt:P21 ?sex . #?item2 wdt:P21 ?sex2 . #filter (?sex = wd:Q6581097 && ?sex2 = wd:Q6581097 {{|}}{{|}} ?sex = wd:Q6581072 && ?sex2 = wd:Q6581072) #filter not exists {?item wdt:P742 []} filter (xsd:string(?item) > xsd:string(?item2) ) filter not exists {?item wdt:P91 wd:Q6636 } #bind (replace(xsd:string(?item),"http://www.wikidata.org/entity/","") as ?itemQid)
#SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en" } . }
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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: count couples with same gender (female)
SELECT (count(distinct ?item) as ?count) WHERE {
?item wdt:P26 ?item2 .
?item wdt:P21 wd:Q6581072 . #female
?item2 wdt:P21 wd:Q6581072 . #female
#?item wdt:P21 wd:Q6581097 . #male
#?item2 wdt:P21 wd:Q6581097 . #male
#?item wdt:P21 ?sex .
#?item2 wdt:P21 ?sex2 .
#filter (?sex = wd:Q6581097 && ?sex2 = wd:Q6581097 {{|}}{{|}} ?sex = wd:Q6581072 && ?sex2 = wd:Q6581072)
#filter not exists {?item wdt:P742 []}
filter (xsd:string(?item) > xsd:string(?item2) )
filter not exists {?item wdt:P91 wd:Q6636 }
#bind (replace(xsd:string(?item),"http://www.wikidata.org/entity/","") as ?itemQid)
#SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en" } .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?count")
v1("?item"):::projected
v2("?item2")
c5(["wd:Q6581072"]):::iri
c2(["wd:Q6636"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P91"--> e0c2
e0v1("?item"):::projected
e0c2(["wd:Q6636"]):::iri
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> c2
v1 --"wdt:P91"--> c2
f1[["http://www.w3.org/2001/XMLSchema#string(?item) > http://www.w3.org/2001/XMLSchema#string(?item2)"]]
f1 --> v1
f1 --> v2
v1 --"wdt:P26"--> v2
v1 --"wdt:P21"--> c5
v2 --"wdt:P21"--> c5
bind3[/"count(?item)"/]
v1 --o bind3
bind3 --as--o v3