I would like some guidance on writing a stored procedure in MS SQL Server 2012 to loop a view I have created. In the view are the employees that have multiple status changes. What I am looking for are employees who have changed their TYPE from PRN to FT or PT or visa versa from one record to the other.
I want to create a table that will store the EmplolyeeID, the older status date as the OLDDate, the older Type as OLDType, the newer status date as NEWDate and the newer Type as NEWType as one record.
The procedure would ignore TYPE that are NULL and move to the next record.
The attached file shows the results of the view. The yellow highlighted records are the one that would be included in the new table.