Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Need Analytical window query help - response (4) by mjasrotia

$
0
0

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


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>