Oracle gets the previous record and the next record lag() and lead() functions

lead() Query the primary key of the current row and the next row of data
 select zzid,c.p from (
  select d.zzid ,lead(d.zzid,1,0) over (order by d.d01007 ) as p from t_d01 d  where exists ( select 1 from  ( select zzid from t_d01 d1 start with d01007 = '001044012025010068' connect by prior d01007=d01027 ) m 
     where d.zzid=m.zzid )    ) c where c.zzid='162';
lag()查询当前行与下一行数据主键     
select zzid,c.p from ( select d.zzid ,lag(d.zzid,1,0) over (order by d.d01007 ) as p from t_d01 d  where exists ( select 1 from  ( select zzid from t_d01 d1 start with d01007 = '001044012025010068' connect by prior d01007=d01027 ) m 
     where d.zzid=m.zzid )    ) c where c.zzid='162';

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324597562&siteId=291194637