query: # parliamentary terms of a single person *plus* all ministerial posts
  # here, Theresa May
  SELECT DISTINCT ?constituencyLabel ?partyLabel ?electionLabel ?ministryLabel ?start ?end ?causeLabel {
   wd:Q264766 p:P39 ?positionStatement . # find all positions held by this person
   { ?positionStatement ps:P39 ?mpterm . ?mpterm wdt:P279* wd:Q16707842 } # filter to positions which are a subclass of UK MP
   union { ?positionStatement ps:P39 ?ministry . 
         { ?ministry wdt:P279* wd:Q83307 } union { ?ministry wdt:P279* wd:Q20086425 } . } # or a subclass of minister/shadow minister
   OPTIONAL { ?positionStatement pq:P768 ?constituency . }  # then find various specific values for each term
   OPTIONAL { ?positionStatement pq:P4100|pq:P102 ?party . }
   OPTIONAL { ?positionStatement pq:P580 ?start . }
   OPTIONAL { ?positionStatement pq:P2715 ?election . }
   OPTIONAL { ?positionStatement pq:P582 ?end . }
   OPTIONAL { ?positionStatement pq:P1534 ?cause . }
   SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
  }
  ORDER BY ?start