solution for Group by interval