query-363b1d8c5d4eb7dd10041786f2bc7d43
two items are considered twins if they’re siblings,
and either the “sibling” statement carries a “type of kinship: twins” qualifier (optionally with a subclass of “twin”),
or both have the same date of birth (with “day” precision)
SELECT ?twin1 ?birth1 ?twin2 ?birth2 ?twin1Label ?birth1Label ?twin2Label ?birth2Label WHERE { ?twin1 wdt:P31 wd:Q5; wdt:P19 ?birth1; p:P3373 ?siblingStatement. ?siblingStatement ps:P3373 ?twin2. { ?siblingStatement pq:P1039/wdt:P279* wd:Q14756018. } UNION { ?twin1 p:P569/psv:P569 ?dateOfBirth. ?twin2 p:P569/psv:P569 ?dateOfBirth. ?dateOfBirth wikibase:timePrecision "11"^^xsd:integer. } ?twin2 wdt:P31 wd:Q5; wdt:P19 ?birth2. FILTER(?birth1 != ?birth2) FILTER(STR(?twin1) < STR(?twin2)) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# two items are considered twins if they’re siblings,
# and either the “sibling” statement carries a “type of kinship: twins” qualifier (optionally with a subclass of “twin”),
# or both have the same date of birth (with “day” precision)
SELECT ?twin1 ?birth1 ?twin2 ?birth2 ?twin1Label ?birth1Label ?twin2Label ?birth2Label WHERE {
?twin1 wdt:P31 wd:Q5;
wdt:P19 ?birth1;
p:P3373 ?siblingStatement.
?siblingStatement ps:P3373 ?twin2.
{ ?siblingStatement pq:P1039/wdt:P279* wd:Q14756018. } UNION
{ ?twin1 p:P569/psv:P569 ?dateOfBirth. ?twin2 p:P569/psv:P569 ?dateOfBirth. ?dateOfBirth wikibase:timePrecision "11"^^xsd:integer. }
?twin2 wdt:P31 wd:Q5;
wdt:P19 ?birth2.
FILTER(?birth1 != ?birth2)
FILTER(STR(?twin1) < STR(?twin2))
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?birth1"):::projected
v4("?birth2"):::projected
v6("?dateOfBirth")
v5("?siblingStatement")
v1("?twin1"):::projected
v2("?twin2"):::projected
a1((" "))
a2((" "))
a3((" "))
c12(["11^^xsd:integer"]):::literal
c14(["bd:serviceParam"]):::iri
c8(["wd:Q14756018"]):::iri
c2(["wd:Q5"]):::iri
c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["str(?twin1) < str(?twin2)"]]
f0 --> v1
f0 --> v2
f1[["?birth1 != ?birth2"]]
f1 --> v3
f1 --> v4
v1 --"p:direct/P31"--> c2
v1 --"p:direct/P19"--> v3
v1 --"p:P3373"--> v5
v5 --"p:statement/P3373"--> v2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:P569"--> a2
a2 --"p:statement/value/P569"--> v6
v2 --"p:P569"--> a3
a3 --"p:statement/value/P569"--> v6
v6 --"wikibase:timePrecision"--> c12
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v5 --"p:qualifier/P1039"--> a1
a1 --"p:direct/P279"--> c8
end
union0r <== or ==> union0l
end
v2 --"p:direct/P31"--> c2
v2 --"p:direct/P19"--> v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c14 --"wikibase:language"--> c16
end