Group by method

I decided to write a post to clarify it for myself and for others