±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)--sum()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(¶þ)--max()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Èý)--row_number() /rank()/dense_rank()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(ËÄ)--lag()/lead()
ÓÐʱºò±¨±íÉÏÃæÐèÒªÏÔʾ¸Ã±Ê²Ù×÷µÄÉÏÒ»²½Öè»òÕßÏÂÒ»²½ÖèµÄÏêϸÐÅÏ¢£¬Õâ¸öʱºò¿ÉÒÔ°´ÕÕÏÂÃæµÄ×ö·¨£º
ÏÈ´´½¨Ê¾Àý±í£º
-- Create table
create 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('Case1','Step4',to_date('20070104','yyyy-mm-dd'));
insert into LEAD_TABLE values('Case1','Step5',to_date('20070105','yyyy-mm-dd'));
insert into LEAD_TABLE values('Case1','Step4',to_date('20070106','yyyy-mm-dd'));
insert into LEAD_TABLE values('Case1','Step6',to_date('20070101','yyyy-mm-dd'));
insert into LEAD_TABLE values('Case1','Step1',to_date('20070201','yyyy-mm-dd'));
insert into LEAD_TABLE values('Case2','Step2',to_date('20070202','yyyy-mm-dd'));
insert into LEAD_TABLE values('Case2','Step3',to_date('20070203','yyyy-mm-dd'));
commit;
ÿһÌõ¼Ç¼¶¼ÄÜÁ¬½Óµ½ÉÏ/ÏÂÒ»ÐеÄÄÚÈÝ
select caseid,stepid,actiondate,lead(stepid) over (partition by caseid order by&
д³ÌÐòµÄÈË£¬ÍùÍùÐèÒª·ÖÎöËùдµÄSQLÓï¾äÊÇ·ñÒѾÓÅ»¯¹ýÁË£¬·þÎñÆ÷µÄÏìӦʱ¼äÓжà¿ì£¬Õâ¸öʱºò¾ÍÐèÒªÓõ½SQLµÄSTATISTICS״ֵ̬À´²é¿´ÁË¡£
ͨ¹ýÉèÖÃSTATISTICSÎÒÃÇ¿ÉÒԲ鿴ִÐÐSQLʱµÄϵͳÇé¿ö¡£Ñ¡ÏîÓÐPROFILE£¬IO £¬TIME¡£½éÉÜÈçÏ£º
SET STATISTICS PROFILE ON£ºÏÔʾ·ÖÎö ......