Select for all entries in table - only interested in the top entry
I have a general question: We have the task to select entries from a certain database table (that possibly holds millions of entries in the productive environment).
We also have an internal table at out hands that holds all candiates e.g a material number for which we want to select the data. That table can hold a few hundred entries.
In this task we are only interested in the 'youngest' entry for a given material - for that we a 'timestamp' in the key fields that should be used.
The data base table has various other key fields so that we can have multiple entries for each material.
What is the best/most efficient way to code it?
One select ?
Select and sort afterwards etc.?
Thanks for any coding suggestion!