title: How can I find the min date by group when data repeats
body: <p>So, my problem is as follows.</p>
  <p>I have a data set with timestamp (date&amp;time). I have another field which shows the status of a file, this status should flow from one stage to the next, but occasionally it will loop back to a prior stage. When this happens I need to show the timestamp when this change occurred.</p>
  <p>As an example, I need to know the MIN date when an item in 'Instructed', this is fine and I have this. What I need to then know is if a file moved to 'Non Instructed' and back to 'Instructed' again, what is the MIN timestamp here - i.e. 07/01/2020 in the example, so effectively ignoring anything prior to the last time a file was at the 'Non Instructed' stage. This loop could happen multiple times, I always need to show the most recent MIN date for a file in the 'Instructed' state. I'm using MS SQL Server.</p>
  <p><img src="https://i.stack.imgur.com/m98a2.png" alt="Time Stamp  Stage" /></p>