Hi Gowtham,
I tried the following at it seems to be working, please check and let me know :
create volatile table brain_twister
(
id integer,
id_type char(1),
stdt date,
endt date
)
primary index (id)
on commit preserve rows;
insert into brain_twister values(1,'A',1130801,1130810);
insert into brain_twister values(1,'A',1130811,1130820);
insert into brain_twister values(2,'B',1130821,1130830);
insert into brain_twister values(2,'B',1130831,1130909);
insert into brain_twister values(1,'A',1130910,1130920);
insert into brain_twister values(1,'A',1130821,1130830);
insert into brain_twister values(1,'A',1130921,1130930);
sel distinct id, id_type, min_stdt,max_endt from
(sel
id,
id_type,
stdt,
endt,
max(endt) over(partition by id,id_type order by stdt,endt reset when stdt -1 > max(endt) over(partition by id,id_type order by stdt, endt rows between unbounded preceding and 1 preceding)) max_endt
,min(stdt) over (partition by id,id_type order by stdt,endt reset when stdt -1 > max(endt) over(partition by id,id_type order by stdt, endt rows between unbounded preceding and 1 preceding)) min_stdt
from brain_twister
) temp
Hi Gowtham,
I tried the following at it seems to be working, please check and let me know :
create volatile table brain_twister
(
id integer,
id_type char(1),
stdt date,
endt date
)
primary index (id)
on commit preserve rows;
insert into brain_twister values(1,'A',1130801,1130810);
insert into brain_twister values(1,'A',1130811,1130820);
insert into brain_twister values(2,'B',1130821,1130830);
insert into brain_twister values(2,'B',1130831,1130909);
insert into brain_twister values(1,'A',1130910,1130920);
insert into brain_twister values(1,'A',1130821,1130830);
insert into brain_twister values(1,'A',1130921,1130930);
sel distinct id, id_type, min_stdt,max_endt from
(sel
id,
id_type,
stdt,
endt,
max(endt) over(partition by id,id_type order by stdt,endt reset when stdt -1 > max(endt) over(partition by id,id_type order by stdt, endt rows between unbounded preceding and 1 preceding)) max_endt
,min(stdt) over (partition by id,id_type order by stdt,endt reset when stdt -1 > max(endt) over(partition by id,id_type order by stdt, endt rows between unbounded preceding and 1 preceding)) min_stdt
from brain_twister
) temp