Select the appropriate query type