SQL Lead Function to take the value when column values changes How to write LEAD function to take value of next record when there is a change in Type.