query-f60001a6dc646b4a72e32422f2f4f1a3
All MPs born since 1945, sorted by month of birth
Use at
- https://query.wikidata.org/sparql
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?month (count(?item) as ?total)
{
?item wdt:P31 wd:Q5 ; p:P39 ?ps . ?ps ps:P39 ?term .
?term wdt:P279* wd:Q16707842 . # all UK MPs
?item wdt:P569 ?born . # with a known birthday
BIND( MONTH(?born) AS ?month ) # identify the month of birth
BIND( YEAR(?born) AS ?year ) # identify the year of birth
FILTER (?year > 1945 )
?item p:P569/psv:P569 ?date_node .
?date_node wikibase:timePrecision "11"^^xsd:integer . # filter only day-precision records
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}
GROUP BY ?month
ORDER BY ?month
#defaultView:LineChart
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?born")
v7("?date_node")
v3("?item"):::projected
v7("?month"):::projected
v4("?ps")
v5("?term")
v8("?total")
v7("?year")
a1((" "))
c12(["11^^xsd:integer"]):::literal
c7(["wd:Q16707842"]):::iri
c16(["en"]):::literal
c14(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
f0[["?year > '1945^^xsd:integer'"]]
f0 --> v7
v3 --"p:direct/P31"--> c3
v3 --"p:P39"--> v4
v4 --"p:statement/P39"--> v5
v5 --"p:direct/P279"--> c7
v3 --"p:direct/P569"--> v6
bind1[/"month-from-dateTime(?born)"/]
v6 --o bind1
bind1 --as--o v7
bind2[/"year-from-dateTime(?born)"/]
v6 --o bind2
bind2 --as--o v7
v3 --"p:P569"--> a1
a1 --"p:statement/value/P569"--> v7
v7 --"wikibase:timePrecision"--> c12
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c14 --"wikibase:language"--> c16
end
bind4[/"count(?item)"/]
v3 --o bind4
bind4 --as--o v8