You need to sign in to do that
Don't have an account?
vishnu vardhan 142
Query to fetch recently created 10 records from object
Hi All,
How to write soql Query to get recently created 10 records from an Object
How to write soql Query to get recently created 10 records from an Object
Select Id,Name,CreatedDate from Account order by CreatedDate desc Limit 10
Instead of Account ==> use your Name.
In Select Query add your required fields( ie, id,name, Created Date)
Thanks,
Maharajan.C
Please try this code:
List <Account> accounts = new List<Account>();
accounts [Select Id from Account Order by CreatedDate DESC LIMIT 10];
Please let me know if you have any other query. If this solution is helpful then please mark it as Best Answer.
Thanks,
Ankit Rathor
I hope you are doing well, You can use this code for Account object.
If you want this for any other object in salesforce then you can change Object name.
Try this ->
list<account> accList = [select id from account order by createdDate DESC limit 10];
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
You can try below snippet of code, it is working according to your requirement.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.