Для Oracle Database 10g
with t as ( select 1 id, 1 val from dual union all select 3 id, 45 val from dual union all select 4 id, null val from dual union all select 5 id, null val from dual union all select 12 id, 48 val from dual union all select 10 id, 5 val from dual union all select 15 id, 10 val from dual) -- select id, val, last_value(val IGNORE NULLS) over (order by ID ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) prev from t order by id Пример вывода данных: ID VAL PREV ---------- ---------- ---------- 1 1 3 45 1 4 45 5 45 10 5 45 12 48 5 15 10 48
Последние комментарии