You need to sign in to do that
Don't have an account?
Michael M
Order by not working in SOQL query
Hello, I am trying to query by Discharge__c (custom object) record with the most recent discharge_date__c.
This is the query I am using:
Discharge__c dis = [select id, name_dob_formula__c, date_of_birth__c, discharge_date__c from discharge__c where Name_DOB_formula__c =: namePlusDob order by discharge_date__c desc limit 1];
However it does not seem to be working. It is querying old discharge__c records with later discharge_date__c's Is there something I should change in the query?
This is the query I am using:
Discharge__c dis = [select id, name_dob_formula__c, date_of_birth__c, discharge_date__c from discharge__c where Name_DOB_formula__c =: namePlusDob order by discharge_date__c desc limit 1];
However it does not seem to be working. It is querying old discharge__c records with later discharge_date__c's Is there something I should change in the query?
Do you see any errors or no results?
Can you try removing limit and desc. 'Name_DOB_formula__c' is used to calculate dates or what it does?
Thanks,
All Answers
Do you see any errors or no results?
Can you try removing limit and desc. 'Name_DOB_formula__c' is used to calculate dates or what it does?
Thanks,
Maybe the above discussion assists you.
For further reference check this too,
https://salesforce.stackexchange.com/questions/7667/soql-result-ordering-in-the-absence-of-an-order-by-clause/7669