query-b17c4b79a25c5831af0f22213f4b5efc
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 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#>
select ?siège ?siègeLabel (sample(?whereLabel) as ?whereLabel2) ?start ?end ?days {
SELECT ?siège ?siègeLabel ?whereLabel ?start ?end ?days WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?siège wdt:P31 wd:Q188055.
BIND(wd:Q4337360 AS ?siège)
OPTIONAL { ?siège wdt:P580 ?start. }
OPTIONAL {
?siège p:P582/psv:P582 ?p582node .
?p582node wikibase:timeValue ?tv . # get the time value
?p582node wikibase:timePrecision ?tp . # get the time precision
BIND(IF(?tp=9,xsd:dateTime(REPLACE(STR(?tv),"-01-01","-12-31")),?tv) AS ?end) # set end date to 31 December if time precision is "year" (9)
}
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)
}
}
group by ?siège ?siègeLabel ?start ?end ?days
order by desc(year(?end)) ?whereLabel2