아래와 같이 데이터를 status 상태 값에 따라,
rnum 값을 연속된 숫자로 구분하고 싶은데요,
윈도우 펑션 이래저래 만져 봐도 답을 잘 못 찾겠네요...ㅠㅜ
고수님들의 도움 부탁 드립니다.
감사합니다.
with tmp as
(select '20171101000000' as tm, 'Y' as status from dual
union all select '20171101000001', 'Y' from dual
union all select '20171101000002', 'N' from dual
union all select '20171101000003', 'N' from dual
union all select '20171101000004', 'Y' from dual
union all select '20171101000005', 'Y' from dual
union all select '20171101000006', 'N' from dual
union all select '20171101000007', 'Y' from dual
)
select *
from tmp;
timestamp, status, rnum
20171101000000, Y, 1
20171101000001, Y, 1
20171101000002, N, null
20171101000003, N, null
20171101000004, Y, 2
20171101000005, Y, 2
20171101000006, N, null
20171101000007, Y, 3