ord_date cnt1 원하는값
2024-11-19 오전 0:53:31.578000 1 1
2024-11-19 오전 8:52:56.278000 1 1
2024-11-20 오전 1:28:25.273000 1 1
2024-11-20 오전 1:31:11.011000 1 1
2024-11-20 오전 1:36:06.398000 1 1
2024-11-20 오전 1:38:15.443000 1 1
2024-11-20 오전 1:38:15.443000 2 2
2024-11-20 오전 1:38:15.443000 2 3
2024-11-20 오후 19:14:02.367000 1 1
위 쿼리는
case when lag(org_date) over(order by org_date) = org_date
then 2 else 2 end
의 결과물 입니다. 혹시 3개 이상의 동일한 날짜가 나온경우 +1씩 증가 시킬수 있는 방법 이 있을까요? ㅜㅜ
다른 방법이라도 혹시 아시는분은 답변 부탁드립니다.
감사합니다.
WITH t AS ( SELECT '2024-11-19 00:53:31.578000' ord_date FROM dual UNION ALL SELECT '2024-11-19 08:52:56.278000' FROM dual UNION ALL SELECT '2024-11-20 01:28:25.273000' FROM dual UNION ALL SELECT '2024-11-20 01:31:11.011000' FROM dual UNION ALL SELECT '2024-11-20 01:36:06.398000' FROM dual UNION ALL SELECT '2024-11-20 01:38:15.443000' FROM dual UNION ALL SELECT '2024-11-20 01:38:15.443000' FROM dual UNION ALL SELECT '2024-11-20 01:38:15.443000' FROM dual UNION ALL SELECT '2024-11-20 19:14:02.367000' FROM dual ) SELECT ord_date , ROW_NUMBER() OVER(PARTITION BY ord_date ORDER BY ord_date) cnt1 , COUNT(*) OVER(PARTITION BY ord_date ORDER BY ord_date ROWS UNBOUNDED PRECEDING) cnt2 FROM t ;