query-242967cf0fa6c6598964e2b16a04313e
Home Secretaries, by how far through their career they were when appointed
cutoff in 2010 as this means they've all now retired
calculation does not take account of breaks in service
select distinct ?person ?personLabel ?appointed ?first_MP ?last_MP
(?last_MP - ?first_MP as ?career_in_days)
(?appointed - ?first_MP as ?experience_when_appointed)
(round((?experience_when_appointed / ?career_in_days)*100) as ?percent_career)
where
{
{ select ?person ?appointed where
{ ?person p:P39 ?hs . ?hs ps:P39 wd:Q2484309 . ?hs pq:P580 ?appointed .
filter (?appointed > "1860-01-01T00:00:00Z"^^xsd:dateTime) . filter (?appointed < "2010-01-01T00:00:00Z"^^xsd:dateTime) }
}
{ select ?person (min(?s) as ?first_MP) (max(?e) as ?last_MP) where
{ ?person p:P39 ?ps . ?ps ps:P39 ?term . ?term wdt:P279 wd:Q16707842 .
?ps pq:P580 ?s . ?ps pq:P582 ?e } group by ?person
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by (?percent_career)
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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#>
# Home Secretaries, by how far through their career they were when appointed
# cutoff in 2010 as this means they've all now retired
# calculation does not take account of breaks in service
select distinct ?person ?personLabel ?appointed ?first_MP ?last_MP
(?last_MP - ?first_MP as ?career_in_days)
(?appointed - ?first_MP as ?experience_when_appointed)
(round((?experience_when_appointed / ?career_in_days)*100) as ?percent_career)
where
{
{ select ?person ?appointed where
{ ?person p:P39 ?hs . ?hs ps:P39 wd:Q2484309 . ?hs pq:P580 ?appointed .
filter (?appointed > "1860-01-01T00:00:00Z"^^xsd:dateTime) . filter (?appointed < "2010-01-01T00:00:00Z"^^xsd:dateTime) }
}
{ select ?person (min(?s) as ?first_MP) (max(?e) as ?last_MP) where
{ ?person p:P39 ?ps . ?ps ps:P39 ?term . ?term wdt:P279 wd:Q16707842 .
?ps pq:P580 ?s . ?ps pq:P582 ?e } group by ?person
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by (?percent_career)