NO V V1
----- ---------- ----------
1 10 10
2 null 10
3 null 10
4 20 20
5 10 10
6 null 10
7 null 10
8 null 10
9 40 40
이런 식으로 구현 하고 싶은데 어떻게 해야 할까요??
아래는 오라클입니다.
WITH t AS
(
SELECT 1 no, 10 v FROM dual
UNION ALL SELECT 2, Null FROM dual
UNION ALL SELECT 3, Null FROM dual
UNION ALL SELECT 4, 20 FROM dual
UNION ALL SELECT 5, 10 FROM dual
UNION ALL SELECT 6, Null FROM dual
UNION ALL SELECT 7, Null FROM dual
UNION ALL SELECT 8, Null FROM dual
UNION ALL SELECT 9, 40 FROM dual
)
SELECT no, v
, LAST_VALUE(v IGNORE NULLS) OVER(ORDER BY no) v1
FROM t
;
|