query-05e6436d2b7266dcb052619ab3691f2f

rq turtle/ttl

TODO

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 p: <http://www.wikidata.org/prop/>
SELECT ?month (count(?item) as ?count)
WHERE 
{
#  ?item wdt:P166/wdt:P361 wd:Q19020.         # winner of an Oscar
#  ?item wdt:P166/wdt:P279* wd:Q7191.         # winner of a Nobel Prize
#  ?item wdt:P106 wd:Q11631.                  # occupation=astronaut
   ?item wdt:P106 wd:Q82955; wdt:P27 wd:Q29 . # occupation=politician, country=spain 

                                              # get dates of birth with month precision
  {?item p:P569/psv:P569 [
                wikibase:timePrecision "10"^^xsd:integer ; 
                wikibase:timeValue ?dob ] .}
  UNION
                                              # get dates of birth with day precision
    {?item p:P569/psv:P569 [
                wikibase:timePrecision "11"^^xsd:integer ; 
                wikibase:timeValue ?dob ] .}
  BIND(month(?dob) as ?month)                 # extract the month
} group by ?month order by ?month

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?count") v3("?dob") v2("?item"):::projected v4("?month"):::projected a2((" ")) a1((" ")) a4((" ")) a3((" ")) c10(["11^^xsd:integer"]):::literal c4(["wd:Q29"]):::iri c2(["wd:Q82955"]):::iri c6(["10^^xsd:integer"]):::literal v2 --"p:direct/P106"--> c2 v2 --"p:direct/P27"--> c4 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; a3 --"wikibase:timePrecision"--> c10 a3 --"wikibase:timeValue"--> v3 v2 --"p:P569"--> a4 a4 --"p:statement/value/P569"--> a3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; a1 --"wikibase:timePrecision"--> c6 a1 --"wikibase:timeValue"--> v3 v2 --"p:P569"--> a2 a2 --"p:statement/value/P569"--> a1 end union0r <== or ==> union0l end bind0[/"month-from-dateTime(?dob)"/] v3 --o bind0 bind0 --as--o v4 bind2[/"count(?item)"/] v2 --o bind2 bind2 --as--o v4