Group query by key name