query-e2909279c64e6529de404d07ae2c3597
Version 2 - using filters select ?item ?itemLabel ?pit ?value WHERE { values ?item {wd:Q84}
?item p:P1082 ?statement. # this block finds a ?pit / ?value combination
?statement ps:P1082 ?value.
?statement pq:P585 ?pit.
filter not exists { # this block finds another ?pit / ?value combination
?item p:P1082 ?statement2.
?statement2 ps:P1082 ?value2.
?statement2 pq:P585 ?pit2.
filter (str(?statement) != str(?statement2))
filter (?pit2>?pit) } # and the filter checks that there is not a more recent
# point in time (?pit2) than the selected ?pit
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
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#>
# Version 2 - using filters
select ?item ?itemLabel ?pit ?value
WHERE
{
values ?item {wd:Q84}
?item p:P1082 ?statement. # this block finds a ?pit / ?value combination
?statement ps:P1082 ?value.
?statement pq:P585 ?pit.
filter not exists { # this block finds another ?pit / ?value combination
?item p:P1082 ?statement2.
?statement2 ps:P1082 ?value2.
?statement2 pq:P585 ?pit2.
filter (str(?statement) != str(?statement2))
filter (?pit2>?pit) } # and the filter checks that there is not a more recent
# point in time (?pit2) than the selected ?pit
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;
v7("?item"):::projected
v2("?pit"):::projected
v1("?pit2")
v3("?statement")
v4("?statement2")
v7("?value"):::projected
v6("?value2")
c5(["bd:serviceParam"]):::iri
c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0f0[["?pit2 > ?pit"]]
e0f0 --> e0v1
e0f0 --> e0v2
e0f1[["str(?statement) != str(?statement2)"]]
e0f1 --> e0v3
e0f1 --> e0v4
e0v5 --"p:P1082"--> e0v4
e0v4 --"p:statement/P1082"--> e0v6
e0v4 --"p:qualifier/P585"--> e0v1
e0v5("?item"):::projected
e0v2("?pit"):::projected
e0v1("?pit2"):::projected
e0v3("?statement"):::projected
e0v4("?statement2"):::projected
e0v6("?value2"):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> v2
f0 --> v3
f0 --> v4
f0 --> v7
f0 --> c1
f0 --> c2
f0 --> v6
f0 --> c3
f1[["?pit2 > ?pit"]]
f1 --> v1
f1 --> v2
f2[["str(?statement) != str(?statement2)"]]
f2 --> v3
f2 --> v4
v7 --"p:P1082"--> v4
v4 --"p:statement/P1082"--> v6
v4 --"p:qualifier/P585"--> v1
bind3[/VALUES ?item/]
bind3-->v7
bind30(["wd:Q84"])
bind30 --> bind3
v7 --"p:P1082"--> v3
v3 --"p:statement/P1082"--> v7
v3 --"p:qualifier/P585"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end