query-33b1f1da2c8953996b9d9f55d0761916
people who were both MPs and MSPs at the same time SELECT DISTINCT ?person ?personLabel ?mpStart ?mpEnd ?mspStart ?mspEnd WHERE { ?person p:P39 ?mspStatement, ?mpStatement. ?mspStatement ps:P39/wdt:P279 wd:Q1711695. ?mpStatement ps:P39/wdt:P279 wd:Q16707842. # find all MSPs and MPs ?mspStatement pq:P580 ?mspStart. # find their MSP term OPTIONAL { ?mspStatement pq:P582 ?mspEnd_. } BIND(COALESCE(?mspEnd_, NOW()) AS ?mspEnd) ?mpStatement pq:P580 ?mpStart. # find their MP term OPTIONAL { ?mpStatement pq:P582 ?mpEnd_. } BIND(COALESCE(?mpEnd_, NOW()) AS ?mpEnd) FILTER ( ?mpStart <= ?mspEnd && ?mspStart <= ?mpEnd ) # check they overlapped SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } ORDER BY ?mpStart
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 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#>
# people who were both MPs and MSPs at the same time
SELECT DISTINCT ?person ?personLabel ?mpStart ?mpEnd ?mspStart ?mspEnd
WHERE {
?person p:P39 ?mspStatement, ?mpStatement.
?mspStatement ps:P39/wdt:P279* wd:Q1711695.
?mpStatement ps:P39/wdt:P279* wd:Q16707842. # find all MSPs and MPs
?mspStatement pq:P580 ?mspStart. # find their MSP term
OPTIONAL { ?mspStatement pq:P582 ?mspEnd_. }
BIND(COALESCE(?mspEnd_, NOW()) AS ?mspEnd)
?mpStatement pq:P580 ?mpStart. # find their MP term
OPTIONAL { ?mpStatement pq:P582 ?mpEnd_. }
BIND(COALESCE(?mpEnd_, NOW()) AS ?mpEnd)
FILTER ( ?mpStart <= ?mspEnd && ?mspStart <= ?mpEnd ) # check they overlapped
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
ORDER BY ?mpStart