query-8ddab8dd3cb303278c6eb315fd1f4f5e
Given names of MPs with date when first MP with that name entered parliament
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#>
SELECT ?givenName ?givenNameLabel ?firstDate WHERE {
{
SELECT ?givenName (MIN(?date) AS ?firstDate) WHERE {
{ ?term wdt:P279* wd:Q16707842. } UNION
{ ?term wdt:P279* wd:Q18015642. } UNION
{ ?term wdt:P279* wd:Q18018860. }
?mp p:P39 ?mpStatement . ?mpStatement ps:P39 ?term .
optional { ?mpStatement pq:P580 ?start. FILTER (!wikibase:isSomeValue(?start)) }
?mp wdt:P735 ?givenName.
?term wdt:P571 ?termstart .
bind(COALESCE(?start, ?termstart) as ?date ) .
# use qualifier dates; if not known use term dates
}
GROUP BY ?givenName
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?firstDate ?givenNameLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?date")
v10("?firstDate"):::projected
v7("?givenName"):::projected
v2("?givenNameLabel"):::projected
v5("?mp")
v6("?mpStatement")
v3("?start")
v4("?term")
v8("?termstart")
c4(["wd:Q18018860"]):::iri
c2(["wd:Q16707842"]):::iri
c11(["bd:serviceParam"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c3(["wd:Q18015642"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P279"--> c4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P279"--> c3
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P279"--> c2
end
union0r <== or ==> union0l
end
v5 --"p:P39"--> v6
v6 --"p:statement/P39"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:qualifier/P580".-> v3
end
v5 --"p:direct/P735"--> v7
v4 --"p:direct/P571"--> v8
bind0[/"?start?termstart"/]
v3 --o bind0
v8 --o bind0
bind0 --as--o v9
bind2[/"min(?date)"/]
v9 --o bind2
bind2 --as--o v10
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end