Putting the group by back into all queries