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
Rishav Dutta 12Rishav Dutta 12 

Need the max Date Time among the Order By on a different field.

Hello All,

I have written the following query:

SELECT A,CreatedDate,Id FROM Object WHERE CreatedDate IN (TODAY, YESTERDAY) ORDER BY A ASC NULLS LAST

Now I get a sample data like followed:

abc::10:00 AM::SFDCID1
abc::11:00 AM::SFDCID2
abc::12:00 AM::SFDCID3
abc::13:00 AM::SFDCID4

So I need the Last record to get selected only. Can anyone help?
abc::14:00 AM::B::SFDCID5

RD@SFRD@SF
Hi Rishav,

Hope this is what you are searching for
SELECT A,CreatedDate,Id FROM Object WHERE CreatedDate IN (TODAY, YESTERDAY) ORDER BY A ASC, CreatedDate DESC LIMIT 1 NULLS LAST

 
Rishav Dutta 12Rishav Dutta 12
No it doesnt work actually... because I have this set of data iterating multiple times with different A Value.

abc::10:00 AM::SFDCID1
abc::11:00 AM::SFDCID2
abc::12:00 AM::SFDCID3
abc::13:00 AM::SFDCID4-- Need this
+++++++++++++++++++++++++++++
​efg::10:00 AM::SFDCID1
efg::11:00 AM::SFDCID2
efg::12:00 AM::SFDCID3
efg::13:00 AM::SFDCID4--- Need this

Thanks anyways!