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
GMASJGMASJ 

Get latest record in soql query

Hi, 
  
  I want to get the latest record from the query below please suggest me a logic. 
list<case> ctendays = [select id, casenumber,subject,createddate,ownerid,owner.name from case where CreatedDate = this_year and subject like :('%' + CaseSubject + '%') order by createddate asc limit 10];

Thanks
SEKAR RAJ.SEKAR RAJ.
Hi,
list<case> ctendays = [select id, casenumber,subject,createddate,ownerid,owner.name from case where CreatedDate = this_year and subject like :('%' + CaseSubject + '%') order by createddate asc limit 10];
// Add Limit as 1 and Use DESC
list<case> ctendays = [select id, casenumber,subject,createddate,ownerid,owner.name from case where CreatedDate = this_year and subject like :('%' + CaseSubject + '%') order by createddate DESC limit 1];

Thanks,
SEKAR RAJ
 
Mr Mehedi HasanMr Mehedi Hasan
@Sekar Raj, thanks! It worked!