Fixed query editing when using 'group by' without 'having'