query-c75907ca4ec2f512919fd8293eb4c161

rq turtle/ttl

Durée des mandats cumulés des Premiers ministres

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
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#>
SELECT ?item ?itemLabel (SUM (?duree_mandat) AS ?duree) WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
    ?item p:P39 ?statement.
    ?statement ps:P39 ?ministere.
    ?ministere (wdt:P279*) wd:Q1587677 ;
      wdt:P17 wd:Q142.
   ?statement pq:P580 ?datedebut.
   ?statement pq:P582 ?datefin.
   BIND( (?datefin - ?datedebut) AS ?duree_mandat )
  FILTER(YEAR(?datedebut) >= 1945).
}
GROUP BY ?item ?itemLabel
ORDER BY DESC (?duree)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?datedebut") v6("?datefin") v8("?duree") v7("?duree_mandat"):::projected v3("?item"):::projected v5("?ministere") v4("?statement") c5(["fr"]):::literal c9(["wd:Q1587677"]):::iri c3(["bd:serviceParam"]):::iri c11(["wd:Q142"]):::iri f0[["year-from-dateTime(?datedebut) >= '1945^^xsd:integer'"]] f0 --> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c3 --"wikibase:language"--> c5 end v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> v5 v5 --"p:direct/P279"--> c9 v5 --"p:direct/P17"--> c11 v4 --"p:qualifier/P580"--> v2 v4 --"p:qualifier/P582"--> v6 bind1[/"?datefin - ?datedebut"/] v6 --o bind1 v2 --o bind1 bind1 --as--o v7 bind3[/"sum(?duree_mandat)"/] v7 --o bind3 bind3 --as--o v8