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

Need Analytical window query help - forum topic by Rakesh71

$
0
0

Hi All,
 
I have the below requirement.
 
Incoming data

ID  Status         Start Date

1   Active              7-Aug 

1   Suspended     8-Aug 

1   Active              9-Aug 

1   Active             10-Aug 

1   Suspended     11-Aug 
 
I should get the below output.

ID  Status      Status_Change_ind     Start Date

1   Active                       0                      7-Aug 

1   Suspended              1                       8-Aug 

1   Active                       1                       9-Aug 

1   Active                       0                      10-Aug 

1   Suspended              1                      11-Aug 

 

When ever a status Change for the same Primary Key i have to generate  Status_Change_ind as 1 . When no change,  Status_Change_ind has to be 0. More than 1 record can come at the same time. So i have to use a Window function order by start date.Please help me with the Query.

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



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