In the image the target is top calculate years since last DX. A year level we want to calculate thw number of years since we have found a DX. Eg There was a dx for id 1 in 2014 so in 2015,2016 and 2017 we are populating the value in incremental manner of year. we find one more DX in 2017 so in the following year we populate 1. the same cycle beging in next ID
The Idea is to implement this logic in Teradata SQL Can someone help how this could be done?