[Oracle]高效的SQL语句之分析函数--lag()/lead()
先创建示例表:-- Create tablecreate table LEAD_TABLE( CASEID VARCHAR2(10), STEPID VARCHAR2(10), ACTIONDATE DATE)tablespace COLM_DATA pctfree 10 initrans 1 maxtrans 255 storage ( initial 64K minextents 1 maxextents unlimited );insert into LEAD_TABLE values('Case1','Step1',to_date('20070101','yyyy-mm-dd'));insert into LEAD_TABLE values('Case1','Step2',to_date('20070102','yyyy-mm-dd'));insert into LEAD_TABLE values('Case1','Step3',to_date('20070103','yyyy-mm-dd'));insert into LEAD_TABLE values('Cas
oracle exists in 的比较
exists 是Oracle sql中的一个函数。表示是否存在符合某种条件的记录。如 select * from A,B where A.id=B.id and exists (SELECT * FROM A WHERE A.type LIKE 'S%') 它和Oracle的另外一个函数IN很相似,你可以比较一下他们的用法,见下:1 性能上的比较比如Select * from T1 where x in ( select y from T2 )执行的过程相当于:select * from t1, ( select distinct y from t2 ) t2 where t1.x = t2.y;相对的select * from t1 where exists ( select null from t2 where y = x )执行的过程相当于:for x in ( select * from t1 ) loop