query-d1ef8d7a4e5328e0164cdea639abcc76
UsageChief of states in the world in 1960 }} # query service } }}query intl{{ # sovereign state in 1960 }}1960=beginTime|?chief_of_state|P6|?country|ValidAtDate{{ # sovereign state in 1960 }}1960=beginTime|Q3624078|instance of|?country|ValidAtDate{{ select ?country ?countryLabel ?chief_of_state ?chief_of_stateLabel { =query|Chief of states in 1960 =title|Chief of states in 1960=label|sparql link{{) query (Chief of states in 1960 }}01-01-2000=beginTime|?value|P131|?item|ValidAtDate{{Full example }} }} }}2000-01-01=beginTime|Q3249|P131|?ville|validAtDate{{ # in the calvados department, in 2000 }}2000-01-01=beginTime|Q484170|P31|?ville|validAtDate{{select ?ville { # french municipalities, in year 2000 =query|sparql{{
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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/>
select ?ville
{
# french municipalities, in year 2000
##### ?ville : P31 Valid in [ 2000-01-01, ] #####
bind ("2000-01-01"^^xsd:date as ?beginTimevilleP31) # bounds
bind ("2000-01-01"^^xsd:date as ?endTimevilleP31)
# get statements for our property P31
?ville p:P31 ?statementvilleP31 .
?statementvilleP31
wikibase:rank ?rank_P31 ; # filter out deprecated statements
ps:P31 wd:Q484170 . # main value of the P31 statement
optional {
?statementvilleP31
pq:P580 ?beginStatementvilleP31 . # begin statement validity date
}
optional {
?statementvilleP31
pq:P582 ?endStatementvilleP31 . # end statement validity date
}
# in case the statement has no "end time", just use "now" as a date
bind(coalesce(?endStatementvilleP31, now()) as ?endStatementvilleP31Final) .
# in case it has no begin time, use arbitrarily year 1
bind(coalesce(?beginStatementvilleP31, "0001-01-01"^^xsd:dat) as ?beginStatementvilleP31Final) .
filter (?rank_P31 != wikibase:DeprecatedRank) . # filter out deprecated ranks
# only get statements valids in the wanted time period
filter (?endStatementvilleP31Final >= ?beginTimevilleP31 && ?beginStatementvilleP31Final <= ?endTimevilleP31 )
#### / ?ville : P31 Valid in [ 2000-01-01, ]
# in the calvados department, in 2000
##### ?ville : P131 Valid in [ 2000-01-01, ] #####
bind ("2000-01-01"^^xsd:date as ?beginTimevilleP131) # bounds
bind ("2000-01-01"^^xsd:date as ?endTimevilleP131)
# get statements for our property P131
?ville p:P131 ?statementvilleP131 .
?statementvilleP131
wikibase:rank ?rank_P131 ; # filter out deprecated statements
ps:P131 wd:Q3249 . # main value of the P131 statement
optional {
?statementvilleP131
pq:P580 ?beginStatementvilleP131 . # begin statement validity date
}
optional {
?statementvilleP131
pq:P582 ?endStatementvilleP131 . # end statement validity date
}
# in case the statement has no "end time", just use "now" as a date
bind(coalesce(?endStatementvilleP131, now()) as ?endStatementvilleP131Final) .
# in case it has no begin time, use arbitrarily year 1
bind(coalesce(?beginStatementvilleP131, "0001-01-01"^^xsd:dat) as ?beginStatementvilleP131Final) .
filter (?rank_P131 != wikibase:DeprecatedRank) . # filter out deprecated ranks
# only get statements valids in the wanted time period
filter (?endStatementvilleP131Final >= ?beginTimevilleP131 && ?beginStatementvilleP131Final <= ?endTimevilleP131 )
#### / ?ville : P131 Valid in [ 2000-01-01, ]
}
Query found at
- https://www.wikidata.org/wiki/Template:ValidAtDate
- https://www.wikidata.org/wiki/Template:ValidAtDate/doc
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v16("?beginStatementvilleP131")
v18("?beginStatementvilleP131Final")
v13("?beginStatementvilleP31")
v15("?beginStatementvilleP31Final")
v15("?beginTimevilleP131")
v11("?beginTimevilleP31")
v17("?endStatementvilleP131")
v18("?endStatementvilleP131Final")
v14("?endStatementvilleP31")
v15("?endStatementvilleP31Final")
v15("?endTimevilleP131")
v11("?endTimevilleP31")
v5("?rank_P131")
v10("?rank_P31")
v15("?statementvilleP131")
v12("?statementvilleP31")
v11("?ville"):::projected
c10(["wd:Q3249"]):::iri
c5(["wd:Q484170"]):::iri
f0[["?endStatementvilleP131Final >= ?beginTimevilleP131?beginStatementvilleP131Final <= ?endTimevilleP131"]]
f0 --> v18
f0 --> v15
f0 --> v18
f0 --> v15
f1[["?rank_P131 != 'wikibase:DeprecatedRank'"]]
f1 --> v5
f2[["?endStatementvilleP31Final >= ?beginTimevilleP31?beginStatementvilleP31Final <= ?endTimevilleP31"]]
f2 --> v15
f2 --> v11
f2 --> v15
f2 --> v11
f3[["?rank_P31 != 'wikibase:DeprecatedRank'"]]
f3 --> v10
bind4[/"'2000-01-01^^xsd:date'"/]
bind4 --as--o v11
bind5[/"'2000-01-01^^xsd:date'"/]
bind5 --as--o v11
v11 --"p:P31"--> v12
v12 --"wikibase:rank"--> v10
v12 --"p:statement/P31"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v12 -."p:qualifier/P580".-> v13
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v12 -."p:qualifier/P582".-> v14
end
bind6[/"?endStatementvilleP31NOW()"/]
v14 --o bind6
bind6 --as--o v15
bind7[/"?beginStatementvilleP31s0001-01-01^^<http://www.w3.org/2001/XMLSchema#dat>'"/]
v13 --o bind7
bind7 --as--o v15
bind8[/"'2000-01-01^^xsd:date'"/]
bind8 --as--o v15
bind9[/"'2000-01-01^^xsd:date'"/]
bind9 --as--o v15
v11 --"p:P131"--> v15
v15 --"wikibase:rank"--> v5
v15 --"p:statement/P131"--> c10
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v15 -."p:qualifier/P580".-> v16
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v15 -."p:qualifier/P582".-> v17
end
bind10[/"?endStatementvilleP131NOW()"/]
v17 --o bind10
bind10 --as--o v18
bind11[/"?beginStatementvilleP131s0001-01-01^^<http://www.w3.org/2001/XMLSchema#dat>'"/]
v16 --o bind11
bind11 --as--o v18