Query-Age-Optimal Scheduling under Sampling and Transmission Constraints