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.
Reading the sum_by code freaks me out, as var as I can tell it would of been doing `null + value` and somehow coming up with a number?