All Forums Database
vinaysid123 2 posts Joined 04/16
30 Apr 2016
Min and Max date for every change in value of a flag

Hi All,
I have a dataset that looks like this:
ID        start_date    end_date       flag
12345  2014-06-04  2014-07-03    I
12345  2014-07-04  2014-08-14    O
12345  2014-07-04  2014-12-01    O
12345  2014-07-04   2015-03-01   O
12345 2015-03-02   2015-05-01    I
12345 2015-05-02    2899-12-31   I
 
And I want the output as
12345 2014-06-04  2014-07-03 I
12345 2014-07-04  2015-03-01 O
12345 2015-03-02  2899-12-31 I
 
Change between I and O can happen multiple times.
Hence I  cant use min max or QUALIFY directly.
Please let me know how can i solve this.
 
Thanks in Advance :)

dnoeth 4628 posts Joined 11/04
02 May 2016

See http://forums.teradata.com/forum/database/from-table-with-daily-log-to-table-with-from-to-dates#comment-147472

Dieter

You must sign in to leave a comment.