日期:2014-05-17 浏览次数:20788 次
insert into c select 1, 10 ,'A' from dual union all select 1 ,10, 'B' from dual union all select 2, 20, 'A' from dual union all select 3 ,30 ,'A' from dual union all select 4 ,40, 'A' from dual union all select 5 ,10 ,'A' from dual union all select 6 ,30 ,'A' from dual union all select 2 ,10 ,'B' from dual union all select 4 ,40 ,'B' from dual union all select 6 ,30 ,'C' from dual commit; --select * from c select distinct dt, type, price, decode(avg(price) over(partition by type order by dt range between 3 preceding and 1 preceding), null, price, avg(price) over(partition by type order by dt range between 3 preceding and 1 preceding)) as t from c