Select IDR , STATUS ,
CASE WHEN STATUS = PREV_STATUS THEN 0 ELSE 1 END AS STATUS_CHANGE_IND , START_DT
FROM
(
Select IDR , Status ,
COALESCE(MAX(STATUS) OVER (PARTITION BY IDR ORDER BY START_DT ROWS BETWEEN 1 preceding and 1 Preceding) , 'NA' ) as PREV_STATUS,
Cnt
from
YOUR_TABLE
) TMP
The above query should work
Thanks
Manik
The above query should work
Thanks
Manik