I'm experiencing something strange with my SOQL results. Our salesforce has a custom sObject named Deals__c and an intermediary object, contact_deals__c which solves the m2m relationship between contacts and deals. I'm trying to grab all the contacts that have at least 5 deals associated with them. To do this, we can simply count how many contact_deals__c.id are associated to the contact.
Contact --> Contact_deals__c = Master --> Detail
Contact_Deals_Count__c is a custom Rollup field that counts how many Contact_deals__c are associated with the contact.
I get two, slightly overlapping results between these two queries:
SELECT name, Contact_Deals_Count__c FROM contact WHERE contact_deals_count__c > 4
SELECT name, Contact_Deals_Count__c, (SELECT id FROM contact_deals__r) FROM contact WHERE contact_deals_count__c > 4
I would think that I should get two identical lists, one having an additional field showing the id's of the Contact_Deals__c. Instead, I get differing results.
How can this be? Especially since we're including only records that the rollup field (contact_deals_count__c) has confirmed has at least 5 Contact_Deals__c associated to them. Why would the second SOQL query leave some of these results out?
Thank you all! You are saving my job!
*EDIT: Seeing the comments here, perhaps there is nothing wrong with the queries and something wrong elsewhere. I'm going to focus on trying to isolate parts of the env to figure it out. The comment to try workbench will likely come in handy ;)