Selecting queries to combine