Fix group by
frustratingly nondeterministic errors were just a bad query?
Merge pull request #1785 from bendiy/4_6_x

Fix group by