标签:
eg1:
with tmp as(
select ‘1‘ id ,‘aa‘ name from dual union all
select ‘2‘ id ,‘bb‘ name from dual
union all
select ‘3‘ id ,‘cc‘ name from dual
)
select a.*,
lag(name,1) over (order by id asc) lag
from tmp a
运行结果是:
eg2
with tmp as(
select ‘1‘ id ,‘aa‘ name from dual union all
select ‘2‘ id ,‘bb‘ name from dual
union all
select ‘3‘ id ,‘cc‘ name from dual
)
select a.*,
lead(name,1) over (order by id asc) lag
from tmp a
标签:
原文地址:http://www.cnblogs.com/xinheng-blog/p/5744368.html