`:` is sufficient indication that you want to bind another variable. List<OpportunityHistory> oppHistories = [SELECT Id, Probability, OpportunityID From OpportunityHistory where OpportunityID IN :opportunities]; Or even better: SELECT Opportunity.OwnerId, Owner.Name, (SELECT Id, OldValue, NewValue FROM Histories WHERE Field = 'Probability') FROM Opportunity WHERE LastModifiedDate = LAST_N_DAYS:7