query: SELECT ?pointintime (COUNT(?item) AS ?count) WHERE {
    SELECT DISTINCT ?pointintime ?item WHERE {
    ?month wdt:P31 wd:Q5151 .
    ?month wdt:P585 ?pointintime  .
    ?item p:P39 ?positionstatement .
    ?positionstatement ps:P39 wd:Q18887908 .
    ?positionstatement pq:P580 ?startdate .
    FILTER( ?startdate < ?pointintime ) .
    OPTIONAL { ?positionstatement pq:P582 ?enddate } .
    FILTER( !BOUND( ?enddate ) || ?pointintime < ?enddate ) .
   }
  } GROUP BY ?pointintime ORDER BY ?pointintime