Fix groupby statement