How to count with group by in projections

Lets assume we have an event EnityCreatedEvent with a field ClientId
EnityCreatedEvent { EntityId, SomeValue, ClientId }

I need to count number of events per ClientId, how to write a projection for doing that?

I haven’t tried it in a while, but I think it would be

fromAll()

partitionBy(e => e.ClientId)

to get the group by