i'm new to MS SQL and i have to carry out the following task.
What i want to output is the time of the first occurence of Stateid = 4, go through the list and return the time when i meet a either stateid = 3 or stateid = 7.
I can't find the methods to use to achieve this. Can someone help please ? 

My table

[![My table](https://i.stack.imgur.com/izDow.png)](https://i.stack.imgur.com/izDow.png)
 .

Desired Result

[![Desired result](https://i.stack.imgur.com/ERmfK.png)](https://i.stack.imgur.com/ERmfK.png)