query-3bac6bc2fa360712584947c580e64da3
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?partner_count (SAMPLE(?female_) AS ?female) (SAMPLE(?male_) AS ?male)
WHERE
{
{ {
SELECT ?partner_count (count(?partner_count) as ?female_) WHERE {
SELECT ?item ?g (count(?p) as ?partner_count) WHERE
{
VALUES ?g {wd:Q6581072}
{
SELECT ?item ?p
WHERE
{
?item wdt:P451 ?p.
?item wdt:P106/wdt:P279* wd:Q108289408 .
} } ?item wdt:P21 ?g.
} group by ?item ?g } group by ?partner_count ?g }}
UNION
{ {
SELECT ?partner_count (count(?partner_count) as ?male_) WHERE {
SELECT ?item ?g (count(?p) as ?partner_count)
WHERE
{
VALUES ?g {wd:Q6581097}
{
SELECT ?item ?p
WHERE
{
?item wdt:P451 ?p.
?item wdt:P106/wdt:P279* wd:Q108289408 .
} } ?item wdt:P21 ?g.
} group by ?item ?g } group by ?partner_count ?g }}
} group by ?partner_count order by desc (?partner_count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?female")
v5("?female_"):::projected
v6("?g")
v3("?item")
v8("?male")
v6("?male_"):::projected
v4("?p")
v6("?partner_count"):::projected
a1((" "))
a2((" "))
c4(["wd:Q108289408"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
bind0[/VALUES ?g/]
bind0-->v6
bind00(["wd:Q6581097"])
bind00 --> bind0
v3 --"wdt:P451"--> v4
v3 --"wdt:P106"--> a2
a2 --"wdt:P279"--> c4
v3 --"wdt:P21"--> v6
bind2[/"count(?p)"/]
v4 --o bind2
bind2 --as--o v6
bind4[/"count(?partner_count)"/]
v6 --o bind4
bind4 --as--o v6
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind5[/VALUES ?g/]
bind5-->v6
bind50(["wd:Q6581072"])
bind50 --> bind5
v3 --"wdt:P451"--> v4
v3 --"wdt:P106"--> a1
a1 --"wdt:P279"--> c4
v3 --"wdt:P21"--> v6
bind7[/"count(?p)"/]
v4 --o bind7
bind7 --as--o v6
bind9[/"count(?partner_count)"/]
v6 --o bind9
bind9 --as--o v5
end
union0r <== or ==> union0l
end
bind12[/"sample(?female_)"/]
v5 --o bind12
bind12 --as--o v7
bind13[/"sample(?male_)"/]
v6 --o bind13
bind13 --as--o v8