query-f027b2c5cb048f01cc9ba4510232bc2b

rq turtle/ttl

TODO

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 ?ministerLabel ?ministryLabel ?start ?end {
  wd:Q15772498 wdt:P580 ?beginning .
  OPTIONAL { wd:Q15772498 wdt:P582 ?finish } .
  ?item p:P39 ?statement .
  {
    ?statement ps:P39/wdt:P360? ?minister .
    {
      ?minister wdt:P279 wd:Q3858501 .
    } UNION {
      ?minister wdt:P279 wd:Q83307;
                wdt:P17 wd:Q38 .
    }
  } UNION {
    ?statement pq:P642 ?ministry .
    ?ministry wdt:P31 wd:Q192350;
              wdt:P17 wd:Q38 .
  } .
  ?statement pq:P580 ?start .
  OPTIONAL { ?statement pq:P582 ?end } .
  FILTER( !BOUND(?end)|| ?end > ?beginning ) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?beginning") v1("?end"):::projected v3("?finish") v4("?item"):::projected v6("?minister") v7("?ministry") v8("?start"):::projected v5("?statement") a1((" ")) c8(["wd:Q3858501"]):::iri c14(["wd:Q192350"]):::iri c20(["en"]):::literal c1(["wd:Q15772498"]):::iri c9(["wd:Q83307"]):::iri c11(["wd:Q38"]):::iri c18(["bd:serviceParam"]):::iri f0[["(not bound(?end) || ?end > ?beginning)"]] f0 --> v1 f0 --> v2 c1 --"p:direct/P580"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; c1 -."p:direct/P582".-> v3 end v4 --"p:P39"--> v5 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"p:qualifier/P642"--> v7 v7 --"p:direct/P31"--> c14 v7 --"p:direct/P17"--> c11 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:statement/P39"--> a1 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; a1 --"p:direct/P360"--> v6 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; end union1r <== or ==> union1l end subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v6 --"p:direct/P279"--> c9 v6 --"p:direct/P17"--> c11 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v6 --"p:direct/P279"--> c8 end union2r <== or ==> union2l end end union0r <== or ==> union0l end v5 --"p:qualifier/P580"--> v8 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P582".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c18 --"wikibase:language"--> c20 end