Function get all groups by id