query-b930ac2269593a64f6f2788ee7ce880a

rq turtle/ttl

Premiers ministres du Québec

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ('Q176' as ?qid) (?pmqid as ?P6) (?position as ?qal1545) (?debut as ?qal580) (?fin as ?qal582) ?pmLabel
WHERE { 
  ?pm p:P39 ?statement .
  ?statement ps:P39 wd:Q2911019 .
  OPTIONAL { ?statement pq:P1545 ?position }
  OPTIONAL {
    ?statement pqv:P580 [wikibase:timeValue ?dt; wikibase:timePrecision ?dp] .
    FILTER STRENDS(?dt, 'Z') .
    BIND(CONCAT('+', STR(?dt), '/', STR(?dp)) as ?debut) .
  }
  OPTIONAL { 
    ?statement pqv:P582 [wikibase:timeValue ?ft; wikibase:timePrecision ?fp] .
    FILTER STRENDS(?ft, 'Z') .
    BIND(CONCAT('+', STR(?ft), '/', STR(?fp)) as ?fin) .
  }
  BIND(STRAFTER(STR(?pm), 'http://www.wikidata.org/entity/') as ?pmqid) .
  FILTER STRSTARTS(?pmqid, 'Q') .
#  MINUS {
#    wd:Q176 p:P6 ?s.
#    ?s ps:P6 ?pm
#  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en". }
}
ORDER BY ?debut

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v12("?P6") v9("?debut"):::projected v8("?dp") v4("?dt") v10("?fin"):::projected v9("?fp") v3("?ft") v5("?pm") v11("?pmqid"):::projected v7("?position"):::projected v13("?qal1545") v14("?qal580") v15("?qal582") v11("?qid") v6("?statement") a1((" ")) a2((" ")) c12(["bd:serviceParam"]):::iri c14(["fr,en"]):::literal c5(["wd:Q2911019"]):::iri f0[["starts-with(?pmqid,'Q')"]] f0 --> v11 v5 --"p:P39"--> v6 v6 --"p:statement/P39"--> c5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P1545".-> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a1 -."wikibase:timeValue".-> v4 a1 --"wikibase:timePrecision"--> v8 v6 --"p:qualifier/value/P580"--> a1 bind1[/"concat('+',str(?dt),'/',str(?dp))"/] v4 --o bind1 v8 --o bind1 bind1 --as--o v9 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; a2 -."wikibase:timeValue".-> v3 a2 --"wikibase:timePrecision"--> v9 v6 --"p:qualifier/value/P582"--> a2 bind2[/"concat('+',str(?ft),'/',str(?fp))"/] v3 --o bind2 v9 --o bind2 bind2 --as--o v10 end bind3[/"substring-after(str(?pm),'http://www.wikidata.org/entity/')"/] v5 --o bind3 bind3 --as--o v11 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end bind4[/"'Q176'"/] bind4 --as--o v11 bind5[/"?pmqid"/] v11 --o bind5 bind5 --as--o v12 bind6[/"?position"/] v7 --o bind6 bind6 --as--o v13 bind7[/"?debut"/] v9 --o bind7 bind7 --as--o v14 bind8[/"?fin"/] v10 --o bind8 bind8 --as--o v15