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
rohitrrohitr 

Query to fetch only records with latest created date

How can i write an soql to fetch records from an object with created date as the most recent present in system?

 

 

Best Answer chosen by rohitr
APathakAPathak
Hi,
Try this ->
list <account> lacc = [select id from account order by createdDate DESC limit 1];

All Answers

APathakAPathak
Hi,
Try this ->
list <account> lacc = [select id from account order by createdDate DESC limit 1];
This was selected as the best answer
Preetichhanda Ray 7Preetichhanda Ray 7
Hi,

I have tried this query, in query editor it's fetching correct result but in code it's not working properly.