query-190d2868bbd1f9d2a404361c6aebfdc1

rq turtle/ttl

This combines the "any term" and a date filter to look for only MPs who have terms which began on or after 1 May 1997, the date of the 1997 general election. (We date all terms as beginning from the day of election; before 1918, where we had multi-day elections, usually this is the first day of the election period.) are still in Parliament today. andWe could link two sets of queries together to find MPs who were serving before 1997,

Use at

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#>
SELECT DISTINCT ?person ?personLabel (MIN(?start2) as ?first) ?seatLabel ?partyLabel ?start WHERE
{
  ?person wdt:P31 wd:Q5 . ?person p:P39 ?ps . 
  ?ps ps:P39 ?term . ?term wdt:P279 wd:Q16707842 .
  ?ps pq:P580 ?start . ?ps pq:P4100 ?party . ?ps pq:P768 ?seat . 
  FILTER NOT EXISTS { ?ps pq:P582 ?end } .

  ?person p:P39 ?ps2 . ?ps2 ps:P39 ?term2 . ?term2 wdt:P279 wd:Q16707842 .
  ?ps2 pq:P580 ?start2 .
  FILTER(?start2 < "1997-05-01T00:00:00Z"^^xsd:dateTime) .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} group by ?person ?personLabel ?seatLabel ?partyLabel ?start

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?end") v11("?first") v7("?party") v4("?person"):::projected v2("?ps") v9("?ps2") v8("?seat") v6("?start"):::projected v1("?start2"):::projected v5("?term") v10("?term2") c8(["wd:Q16707842"]):::iri c15(["en"]):::literal c13(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri f0[["?start2 < '1997-05-01T00:00:00Z^^xsd:dateTime'"]] f0 --> v1 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v2("?end"):::projected e0v1("?ps"):::projected end f1--EXISTS--> f1e0 f1 --> v2 f1 --> c2 f1 --> v3 v2 --"p:qualifier/P582"--> v3 v4 --"p:direct/P31"--> c4 v4 --"p:P39"--> v2 v2 --"p:statement/P39"--> v5 v5 --"p:direct/P279"--> c8 v2 --"p:qualifier/P580"--> v6 v2 --"p:qualifier/P4100"--> v7 v2 --"p:qualifier/P768"--> v8 v4 --"p:P39"--> v9 v9 --"p:statement/P39"--> v10 v10 --"p:direct/P279"--> c8 v9 --"p:qualifier/P580"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end bind3[/"min(?start2)"/] v1 --o bind3 bind3 --as--o v11