Fix groupBy query

Closes #5