Hi
I have tried the above code but I dont seem to be getting the expected results. Example table
myTab(c1 varchar(10), c2 varchar(10), c3 varchar(10), sd date ed date);
example
data row1: 'A','B','C','2012-01-01','2012-01-02'
data row2: 'A','B','C','2012-01-03','2012-01-09'
data row 3 'A+','B','C','2012-01-10','2012-01-19'
data row 4 'A','B','C','2012-01-20','9999-12-31'
What I expected back was three rows in which data row 1 and data row2 are 'combined', however this is not the case.
The query I use is :-
Select c1
,c2
,c3
,sd
,coalesce(min(prev_end_time)
over (partition by c1,c2,c3
order by sd
rows between 1 following and 1 following), max_end_time) as end_time
From
(
Select c1
,c2
,c3
,sd
,max(ed)
over (partition by c1,c2,c3
order by sd
rows between unbounded preceding and 1 preceding) as prev_end_time
,max(ed) over (partition by c1,c2,c3) as max_end_time
From insight.if_test1
qualify sd > prev_end_time or prev_end_time is null
) as dt
H E L P
Hi
I have tried the above code but I dont seem to be getting the expected results. Example table
myTab(c1 varchar(10), c2 varchar(10), c3 varchar(10), sd date ed date);
example
data row1: 'A','B','C','2012-01-01','2012-01-02'
data row2: 'A','B','C','2012-01-03','2012-01-09'
data row 3 'A+','B','C','2012-01-10','2012-01-19'
data row 4 'A','B','C','2012-01-20','9999-12-31'
What I expected back was three rows in which data row 1 and data row2 are 'combined', however this is not the case.
The query I use is :-
H E L P