function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BeautifulDrifterBeautifulDrifter 

Help with an Aggragate using SOQL Relation Value Comparison

 AggregateResult[] groupedResults
            = [SELECT Detail_Question__r.PSQ_Applications__c, count(Id)
               FROM PSQ_Detail__c
               WHERE Detail_Question__r.App_dependency__c = Answer__c 
               AND PSQ_Header__c = :stdCtrl.getId()
               GROUP BY Detail_Question__r.PSQ_Applications__c];

I am getting an error on the where clause: expecting a colon, found 'Answer__c'

Any help would be appreciated.  Thanks in advance!
Best Answer chosen by BeautifulDrifter
John TowersJohn Towers
That query won't work because SOQL doesn't allow field to field comparisons. There's an answer here (https://help.salesforce.com/articleView?id=000187460&type=1) that documents the issue and suggests using a formula to achieve this instead.

All Answers

John TowersJohn Towers
That query won't work because SOQL doesn't allow field to field comparisons. There's an answer here (https://help.salesforce.com/articleView?id=000187460&type=1) that documents the issue and suggests using a formula to achieve this instead.
This was selected as the best answer
BeautifulDrifterBeautifulDrifter
Quick and dirty...thanks John.