Andrew Gray, version of the above, includes the MPs who were the first of their given name
SELECT ?givenName ?givenNameLabel ?firstDate ?mp ?mpLabel WITH {
SELECT ?givenName (MIN(?date) AS ?firstDate) WHERE {
{ ?mpStatement ps:P39/wdt:P279? wd:Q16707842. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18015642. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18018860. }
?mpStatement pq:P580 ?date.
?mp p:P39 ?mpStatement;
wdt:P735 ?givenName.
}
GROUP BY ?givenName
} AS %givenNames WITH {
SELECT DISTINCT ?givenName ?firstDate ?mp WHERE {
INCLUDE %givenNames.
?mpStatement pq:P580 ?firstDate.
{ ?mpStatement ps:P39/wdt:P279? wd:Q16707842. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18015642. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18018860. }
?mp p:P39 ?mpStatement;
wdt:P735 ?givenName.
}
} AS %mps WHERE {
INCLUDE %mps.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?firstDate ?givenNameLabel
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#>
#Andrew Gray, version of the above, includes the MPs who were the first of their given name
SELECT ?givenName ?givenNameLabel ?firstDate ?mp ?mpLabel WHERE {
{
SELECT DISTINCT ?givenName ?firstDate ?mp WHERE {
{
SELECT ?givenName (MIN(?date) AS ?firstDate) WHERE {
{ ?mpStatement ps:P39/wdt:P279? wd:Q16707842. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18015642. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18018860. }
?mpStatement pq:P580 ?date.
?mp p:P39 ?mpStatement;
wdt:P735 ?givenName.
}
GROUP BY ?givenName
}
?mpStatement pq:P580 ?firstDate.
{ ?mpStatement ps:P39/wdt:P279? wd:Q16707842. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18015642. } UNION
{ ?mpStatement ps:P39/wdt:P279? wd:Q18018860. }
?mp p:P39 ?mpStatement;
wdt:P735 ?givenName.
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?firstDate ?givenNameLabel