query-05b1fae801a811730d5e9e67948a1fff
Durée des sièges dans l'histoire v3
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select ?siège ?siègeLabel (sample(?whereLabel) as ?whereLabel2) ?start ?tp_end ?tv_end ?end ?days ?years ?_articleFR ?_articleEN {
SELECT ?siège ?siègeLabel ?whereLabel ?start ?tp_end ?tv_end ?end ?days ?years ?_articleFR ?_articleEN WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?siège wdt:P31 wd:Q188055.
OPTIONAL { ?siège wdt:P580 ?start. }
OPTIONAL {
?siège p:P582/psv:P582 ?p582node.
?p582node wikibase:timeValue ?tv_end . # get the time value
?p582node wikibase:timePrecision ?tp_end . # get the time precision
BIND(
IF(?tp_end=9,?tv_end + "P1Y"^^xsd:duration - "P1D"^^xsd:duration,# set end date to 31 December if time precision is "year" (9)
IF(?tp_end=10,?tv_end + "P1M"^^xsd:duration - "P1D"^^xsd:duration,# set end date to 28th if time precision is "month" (10)
?tv_end))
AS ?end).
}
OPTIONAL { ?siège wdt:P276 ?where. }
OPTIONAL { ?siège p:P2047/psn:P2047/wikibase:quantityAmount ?lengthNorm.}
BIND(COALESCE(?lengthNorm/86400,(?end - ?start+1)) as ?days)
BIND(?days/365.00 as ?years)
OPTIONAL {
?_articleFR schema:about ?siège.
?_articleFR schema:isPartOf <https://fr.wikipedia.org/>.
?_articleEN schema:about ?siège.
?_articleEN schema:isPartOf <https://en.wikipedia.org/>.
}
}
}
group by ?siège ?siègeLabel ?start ?tp_end ?tv_end ?end ?days ?years ?_articleFR ?_articleEN
order by desc(?years) ?whereLabel2
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v13("?_articleEN"):::projected
v12("?_articleFR"):::projected
v11("?days"):::projected
v8("?end"):::projected
v10("?lengthNorm")
v5("?p582node")
v3("?siège"):::projected
v4("?start"):::projected
v7("?tp_end"):::projected
v6("?tv_end"):::projected
v9("?where")
v14("?whereLabel"):::projected
v15("?whereLabel2")
v12("?years"):::projected
a1((" "))
a2((" "))
a3((" "))
c18([https://fr.wikipedia.org/]):::iri
c19([https://en.wikipedia.org/]):::iri
c2(["bd:serviceParam"]):::iri
c6(["wd:Q188055"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v3 --"p:direct/P31"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P580".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:P582".-> a1
a1 --"p:statement/value/P582"--> v5
v5 --"wikibase:timeValue"--> v6
v5 --"wikibase:timePrecision"--> v7
bind0[/"if(?tp_end = '9^^xsd:integer',?tv_end + 'P1Y^^xsd:duration' - 'P1D^^xsd:duration',if(?tp_end = '10^^xsd:integer',?tv_end + 'P1M^^xsd:duration' - 'P1D^^xsd:duration',?tv_end))"/]
v7 --o bind0
v6 --o bind0
bind0 --as--o v8
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P276".-> v9
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:P2047".-> a2
a2 --"p:statement/value-normalized/P2047"--> a3
a3 --"wikibase:quantityAmount"--> v10
end
bind1[/"?lengthNorm / '86400^^xsd:integer'?end - ?start + '+1^^xsd:integer'"/]
v10 --o bind1
v8 --o bind1
v4 --o bind1
bind1 --as--o v11
bind2[/"?days / '365.00^^xsd:decimal'"/]
v11 --o bind2
bind2 --as--o v12
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v12 -."schema:about".-> v3
v12 --"schema:isPartOf"--> c18
v13 --"schema:about"--> v3
v13 --"schema:isPartOf"--> c19
end
bind4[/"sample(?whereLabel)"/]
v14 --o bind4
bind4 --as--o v15