query-ecc186a72571067ab6f4f6848d880b54
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
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 ?position_heldLabel ?start_time ?replacesLabel ?end_time ?replaced_byLabel ?end_causeLabel WHERE {
{
SELECT DISTINCT ?item {
?item wdt:P39/wdt:P361 wd:Q112014 . # get positions that are part of (P361) Cabinet of the United Kingdom
?item p:P39 [pq:P580 ?startdate; rdf:type wikibase:BestRank] .
FILTER(YEAR(?startdate)>=1945) # limit to start dates from 1945
}
}
?item p:P39 ?p39stm .
?p39stm rdf:type wikibase:BestRank .
?p39stm ps:P39 ?position_held .
OPTIONAL { ?p39stm pq:P580 ?start_time }
OPTIONAL { ?p39stm pq:P1365 ?replaces }
OPTIONAL { ?p39stm pq:P582 ?end_time }
OPTIONAL { ?p39stm pq:P1366 ?replaced_by }
OPTIONAL { ?p39stm pq:P1534 ?end_cause }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?itemLabel ?start_time
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?end_cause")
v8("?end_time"):::projected
v4("?item"):::projected
v1("?itemLabel"):::projected
v5("?p39stm")
v6("?position_held")
v9("?replaced_by")
v7("?replaces")
v2("?start_time"):::projected
v3("?startdate")
a1((" "))
a2((" "))
c7(["wikibase:BestRank"]):::iri
c15(["bd:serviceParam"]):::iri
c4(["wd:Q112014"]):::iri
c17(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["year-from-dateTime(?startdate) >= '1945^^xsd:integer'"]]
f0 --> v3
v4 --"p:direct/P39"--> a1
a1 --"p:direct/P361"--> c4
a2 --"p:qualifier/P580"--> v3
a2 --"a"--> c7
v4 --"p:P39"--> a2
v4 --"p:P39"--> v5
v5 --"a"--> c7
v5 --"p:statement/P39"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P580".-> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P1365".-> v7
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P582".-> v8
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P1366".-> v9
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:qualifier/P1534".-> v10
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
end