query-b4cd64d261f3a6e2f4c776c4b7822deb
TODO
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?en_label ?pit1 ?value1 ?pit2 ?value2
WHERE
{
?item wdt:P106 wd:Q10873124. # occupation of chess player
# values ?item {wd:Q183250} # the JuditP values statement
?item wdt:P27 wd:Q145. # UK citizen - comment out if you want to enstate the JuditP values statement
?item p:P1087 ?statement1. # find first date block
?statement1 ps:P1087 ?value1.
?statement1 pqv:P585 ?node1.
{?node1 wikibase:timePrecision "11"^^xsd:integer.}
UNION
{?node1 wikibase:timePrecision "10"^^xsd:integer.}
?node1 wikibase:timeValue ?pit1.
?item p:P1087 ?statement2. # find second date block
?statement2 ps:P1087 ?value2.
?statement2 pqv:P585 ?node2.
{?node2 wikibase:timePrecision "11"^^xsd:integer.}
UNION
{?node2 wikibase:timePrecision "10"^^xsd:integer.}
?node2 wikibase:timeValue ?pit2.
filter(month(?pit1)=month(?pit2)) # logic
filter(year(?pit1)=year(?pit2))
filter (str(?statement1)>str(?statement2))
optional {?item rdfs:label ?en_label. filter(lang(?en_label)="en")}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?en_label"):::projected
v6("?item"):::projected
v8("?node1")
v10("?node2")
v3("?pit1"):::projected
v4("?pit2"):::projected
v1("?statement1")
v2("?statement2")
v7("?value1"):::projected
v9("?value2"):::projected
c10(["11^^xsd:integer"]):::literal
c3(["wd:Q10873124"]):::iri
c5(["wd:Q145"]):::iri
c11(["10^^xsd:integer"]):::literal
f0[["str(?statement1) > str(?statement2)"]]
f0 --> v1
f0 --> v2
f1[["year-from-dateTime(?pit1) = year-from-dateTime(?pit2)"]]
f1 --> v3
f1 --> v4
f2[["month-from-dateTime(?pit1) = month-from-dateTime(?pit2)"]]
f2 --> v3
f2 --> v4
v6 --"p:direct/P106"--> c3
v6 --"p:direct/P27"--> c5
v6 --"p:P1087"--> v1
v1 --"p:statement/P1087"--> v7
v1 --"p:qualifier/value/P585"--> v8
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v8 --"wikibase:timePrecision"--> c11
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v8 --"wikibase:timePrecision"--> c10
end
union0r <== or ==> union0l
end
v8 --"wikibase:timeValue"--> v3
v6 --"p:P1087"--> v2
v2 --"p:statement/P1087"--> v9
v2 --"p:qualifier/value/P585"--> v10
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v10 --"wikibase:timePrecision"--> c11
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v10 --"wikibase:timePrecision"--> c10
end
union1r <== or ==> union1l
end
v10 --"wikibase:timeValue"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:label".-> v5
end