query-f201088fcae71a781bd342e64fb51b30

rq turtle/ttl

Period when posts were part of Scottish Cabinet were once part of the Cabinet, but no long are, even though the position itself still exists. (Q1807003)Lord Advocate This one is slightly tricky, as some posts (e.g.

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 DISTINCT ?post ?postLabel ?post_from ?post_to ?cabinetLabel {
  ?cabinet wdt:P31 wd:Q640506 ; wdt:P1001 wd:Q22; wdt:P571 ?inception .
  OPTIONAL { ?cabinet wdt:P576 ?dissolution }
  BIND(if(BOUND(?dissolution), ?dissolution, NOW()) as ?effective_dissolution)

  ?cabinet p:P2670 ?post_statement .
  ?post_statement ps:P2670 ?post .
  OPTIONAL { ?post_statement pq:P580 ?post_start }
  BIND(if(BOUND(?post_start), ?post_start, ?inception) as ?post_from)

  OPTIONAL { ?post_statement pq:P582 ?post_end }
  BIND(if(BOUND(?post_end), ?post_end, ?effective_dissolution) as ?post_to)

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?postLabel ?inception

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?cabinet") v4("?dissolution") v5("?effective_dissolution") v2("?inception") v7("?post"):::projected v1("?postLabel"):::projected v10("?post_end") v9("?post_from"):::projected v8("?post_start") v6("?post_statement") v11("?post_to"):::projected c14(["en"]):::literal c4(["wd:Q22"]):::iri c12(["bd:serviceParam"]):::iri c2(["wd:Q640506"]):::iri v3 --"p:direct/P31"--> c2 v3 --"p:direct/P1001"--> c4 v3 --"p:direct/P571"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P576".-> v4 end bind0[/"if(bound(?dissolution),?dissolution,NOW())"/] v4 --o bind0 bind0 --as--o v5 v3 --"p:P2670"--> v6 v6 --"p:statement/P2670"--> v7 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P580".-> v8 end bind1[/"if(bound(?post_start),?post_start,?inception)"/] v8 --o bind1 v2 --o bind1 bind1 --as--o v9 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P582".-> v10 end bind2[/"if(bound(?post_end),?post_end,?effective_dissolution)"/] v10 --o bind2 v5 --o bind2 bind2 --as--o v11 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end