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
Jaymin Sutarwala 7Jaymin Sutarwala 7 

Need help with SOQL query

I am facing issues coming up with a SOQL query. We have a custom object 'Quote History' which has master detail relationship to Quote object. The Quote History object  store the field modified timestamp, field old value and field new value for some of the fields on the Quote object. 
User-added image

I want to write SOQL query that can give me the max(field modified timestamp), the most recent update made to the field] as well as the new value for a particular field for each Quote and Proposal number combination.
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi Jaymin,

You can use SOQL something like this.

select id, (select id,lastmodifieddate from QuoteHistory__r order by lastmodifieddate DESC  limit 1) from Quote .

Make sure to use appropriate object name and relationship name in query.