0

My SOQL query results syntax error can you check and confirm if I made any mistake

LIst <AggregateResult> results = [SELECT ZTS_EU_Contact__C con,Max(ZTS_EU_call__r.ZTS_EU_Start_Date_Time__c) date from Attendee__C WHERE ID IN: listAttID AND ZTS_EU_Status__c = 'Submitted' OR ZTS_EU_Status__c ='Completed' Group BY ZTS_EU_Contact__C];

In WHERE condition part I have newly added this part - AND ZTS_EU_Status__c = 'Submitted' OR ZTS_EU_Status__c ='Completed'

error : Error: Compile Error: Expecting ']' but was: 'OR'

Any inputs that would be great

Thanks, Manoj

1
  • 1
    Try to add brackets, it should work then WHERE ID IN: listAttID AND (ZTS_EU_Status__c = 'Submitted' OR ZTS_EU_Status__c ='Completed') or add it as list: WHERE ID IN: listAttID AND ZTS_EU_Status__c IN ('Submitted', 'Completed') Nov 17, 2021 at 13:49

1 Answer 1

1

You need to mention the OR condition in Single block OR Use IN Operator to mention more then one values. then only it's can be work properly in SOQL.

Can you please try as follows,

LIst <AggregateResult> results = [SELECT ZTS_EU_Contact__C con,Max(ZTS_EU_call__r.ZTS_EU_Start_Date_Time__c) date from Attendee__C WHERE ID IN: listAttID AND (ZTS_EU_Status__c = 'Submitted' OR ZTS_EU_Status__c ='Completed') Group BY ZTS_EU_Contact__C];

OR

LIst <AggregateResult> results = [SELECT ZTS_EU_Contact__C con,Max(ZTS_EU_call__r.ZTS_EU_Start_Date_Time__c) date 
                                   from Attendee__C 
                                   WHERE ID IN: listAttID AND 
                                         ZTS_EU_Status__c IN ('Submitted','Completed') 
                                   Group BY ZTS_EU_Contact__C];

Please let me know if it helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .