query-bd80caaf7f7cbee64910b803ecf97f66

rq turtle/ttl

Most and least common birthdays among MPs

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 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 ?birthday (count(distinct ?item) as ?total) WHERE
{
 ?item wdt:P31 wd:Q5 ; p:P39 ?ps . ?ps ps:P39 ?term .
 ?term wdt:P279* wd:Q16707842 .      # UK MP (let's only look at post-1801 for now)
 ?item wdt:P569 ?born .              # with a known birthday
 BIND( DAY(?born) AS ?day )          # identify the month of birth
 BIND( MONTH(?born) AS ?month )      # identify the month of birth
 bind(concat(str(?day),"/",str(?month)) as ?birthday)
 ?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 ?birthday
ORDER BY ?total

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?birthday"):::projected v5("?born") v9("?date_node") v6("?day") v2("?item"):::projected v7("?month") v3("?ps") v4("?term") v10("?total") a1((" ")) c11(["11^^xsd:integer"]):::literal c6(["wd:Q16707842"]):::iri c15(["en"]):::literal c13(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri v2 --"p:direct/P31"--> c2 v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> v4 v4 --"p:direct/P279"--> c6 v2 --"p:direct/P569"--> v5 bind0[/"day-from-dateTime(?born)"/] v5 --o bind0 bind0 --as--o v6 bind1[/"month-from-dateTime(?born)"/] v5 --o bind1 bind1 --as--o v7 bind2[/"concat(str(?day),'/',str(?month))"/] v6 --o bind2 v7 --o bind2 bind2 --as--o v8 v2 --"p:P569"--> a1 a1 --"p:statement/value/P569"--> v9 v9 --"wikibase:timePrecision"--> c11 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end bind4[/"count(?item)"/] v2 --o bind4 bind4 --as--o v10