fix sampled query grouping