http://cafe.naver.com/prodba/47529
-- 참조 질문
select status
, min(time_line) from_time
, max(time_line) to_time
, max(time_line) - min(time_line) cnt
from ( select time_line
, status
, time_line - rownumber() over (partition by status order by time_line) grp
from tb
)
group by status, grp
order by from_time
;
--- 여기서 rownum 은 time_line 에 간격을 찾기 위해서 사용 한 거구나