LAG與LEAD 分析函數的用法
LAG(EXPRESSION,<OFFSET>,<DEFAULT>)SQL> with a as (select 1 id,'a' name from dual 2 union 3 select 2 id,'b' name from dual 4 union 5 select 3 id,'c' name from dual 6 union 7 select 4 id,'d' name from dual 8 union 9 select 5 id,'e' name from dual 10 ) 11 select id,name,lag(id,1,'')over(order by name) from a 12 / ID NAME LAG(ID,1,'')OVER(ORDERBYNAME)---------