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
Temple SutfinTemple Sutfin 

Quirky query. ORDER BY clause not working

Anyone have an idea why this query works just fine:

soql = 'SELECT Name,Status__c,Contractor__c,Name_Of_Job__c,Job__r.Type__c FROM Bid__c WHERE name != null'; runQuery();       }

 

 

but this one fails:

soql = 'SELECT Name,Status__c,Contractor__c,Name_Of_Job__c,Job__r.Type__c FROM Bid__c WHERE name != null ORDER BY Name_Of_Job__c'; runQuery();       }

 

 

I am not seeing the issue with the ORDER BY clause.

ForcepowerForcepower
What error do you get?
Temple SutfinTemple Sutfin

I get this:

 

System.QueryException: unexpected token: 'ORDER'

ForcepowerForcepower
I'd suggest running your query in Workbench or in the Force.com IDE and see if you get the same error there. Doesn't seem to be anything wrong with it.
Temple SutfinTemple Sutfin

Yeah, I am not getting any errors there either.  Hence the confuzzlement.

 

 

ForcepowerForcepower

One other thing you could try is to run it as a static query:

 

List<Bid__c> bidList = [SELECT Name,Status__c,Contractor__c,Name_Of_Job__c,Job__r.Type__c FROM Bid__c WHERE name != null ORDER BY Name_Of_Job__c]; 
s_k_as_k_a

Try like this

 

'SELECT Name,Status__c,Contractor__c,Name_Of_Job__c,Job__r.Type__c FROM Bid__c WHERE name != null '+' ORDER BY Name_Of_Job__c'

CaptainObviousCaptainObvious

Hard to tell from your example, but Is there a line break before the ORDER BY clause?

 

If so, make sure the entire string is on the same line.