query-42089faa140427ae9a10db0a303cdf2e
title: check partner for same gender (male) SELECT distinct ?item ?itemQid ?itemLabel ?item2 ?item2Label WHERE { ?item wdt:P26 ?item2 . ?item wdt:P21 wd:Q6581097 . ?item2 wdt:P21 wd:Q6581097 . #?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" } . } order by ?item offset 0 limit 100
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: check partner for same gender (male)
SELECT distinct ?item ?itemQid ?itemLabel ?item2 ?item2Label WHERE {
?item wdt:P26 ?item2 .
?item wdt:P21 wd:Q6581097 .
?item2 wdt:P21 wd:Q6581097 .
#?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" } .
} order by ?item offset 0 limit 100
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?item"):::projected
v2("?item2"):::projected
c7(["bd:serviceParam"]):::iri
c5(["wd:Q6581097"]):::iri
c9(["de,en"]):::literal
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
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end