sum 开窗函数 oracle,oracle开窗函数案例详解

一、建表和数据准备

create table t_window(

name varchar2(32),

orderdate varchar2(32),

cost varchar2(32)

)

select * from t_window

insert all into t_window values('jack','2015-01-01','10')

into t_window values('tony','2015-01-02','15')

into t_window values('jack','2015-02-03','23')

into t_window values('tony','2015-01-04','29')

into t_window values('jack','2015-01-05','46')

into t_window values('jack','2015-04-06','42')

into t_window values('tony','2015-01-07','50')

into t_window values('jack','2015-01-08','55')

into t_window values('mart','2015-04-08','62')

into t_window values('mart','2015-04-09','68')

into t_window values('neil','2015-05-10','12')

into t_window values('mart','2015-04-11','75')

into t_window values('neil','2015-06-12','80')

into t_window values('mart','2015-04-13','94')

select 1 from dual;

commit;

二、实例

聚合函数+over

max

因为加上了order by 所以默认从起始行到当前行

select name,orderdate,cost,max(cost) over

你可能感兴趣的:(sum,开窗函数,oracle)