Introduce count_by with a secondary field

I've re-used "count_by" the expression because there isn't ambiguity, but happy to give it a different name too if people prefer.
The mind boggles at the series of circumstances that resulted in `days_since_earliest_by`, `count_by` and `sum_by` all working when this method was completely broken.