A little context: you need to track the amount of products in an account (inventory management). To do this, you have a custom object that acts as a junction table between an account and a product. This object has a
quantity field that has field history enabled.
Id Name Product__c (lookup) Account__c (lookup) Quantity__c (history enabled)
Now if you need to generate a report to get the exact amount of items in a certain account on a certain date, how can you filter just the last modification per item (the newest
NewValue on the history per item)?
My main issue here, I believe, is that I don't know how to use SOQL to get only the latest history entry up to a date. This can become an issue for a huge history, because if I want to get a history, say, from January, internally I'd have to query everything in the history just to know what I had in stock until 1/Jan. The remaining records would be used to calculate what happened in the month.