请问各位,
我现在有一些数据是用分析函数动态产生、按时间段(小时)和产品分组的,但它们现在是不连续的(因为有些时段没有数据)。
我现在想实现这样的功能:如果当前时段没有数据,则把最相邻的上一个时段数据延续到当前时段,有什么好办法呢?
比如说10点钟,11点钟,14点钟有数据,但12、13点钟不连续了;现在要把11点钟的数据延续到12、13点钟。
急用,请各位多多指教。
我现在有一些数据是用分析函数动态产生、按时间段(小时)和产品分组的,但它们现在是不连续的(因为有些时段没有数据)。
我现在想实现这样的功能:如果当前时段没有数据,则把最相邻的上一个时段数据延续到当前时段,有什么好办法呢?
比如说10点钟,11点钟,14点钟有数据,但12、13点钟不连续了;现在要把11点钟的数据延续到12、13点钟。
急用,请各位多多指教。
解决方案 »
- oracle pctfree+pctused=100时,oracle会怎么做
- oracle11gR2安装
- 如何能把下面两个sql写成一个sql,麻烦大家
- 问题找到了,但不知道原因。
- 用户买了套oracle9i for win ,有了licenses是不可以申请csi号,再在Metalink注册,怎么申请csi号?
- 如果让一个字段达到ACCESS的自动编号的效果,改如何处理?
- 关于ORACLE 分区表
- orical 9i for win2k/2003 server有几张碟?
- 急!!!求助!!ogg问题! 源端和目标端 7809端口建立不上
- 求助,Oracle10 bin下所有应用程序打开,都提示已停止工作
- shutdown abort后出现Ora-00439:feature not enabled:Real Application Clusters错误,怎么解决,
- 请高手帮忙分析一下用哪种方式比较好
SQL> create table t1(d date);Table createdSQL> create table t2(d date,v number);Table createdSQL> insert into t1 select trunc(sysdate,'MM')+rownum-1 from all_objects where rownum<=31;31 rows insertedSQL> insert into t2 values(to_date('2006-12-3','yyyy-mm-dd'),4231);1 row insertedSQL> insert into t2 values(to_date('2006-12-13','yyyy-mm-dd'),2432);1 row insertedSQL> insert into t2 values(to_date('2006-12-8','yyyy-mm-dd'),6013);1 row insertedSQL> insert into t2 values(to_date('2006-12-17','yyyy-mm-dd'),1044);1 row insertedSQL> insert into t2 values(to_date('2006-12-19','yyyy-mm-dd'),7695);1 row insertedSQL> insert into t2 values(to_date('2006-12-20','yyyy-mm-dd'),4586);1 row insertedSQL> insert into t2 values(to_date('2006-12-25','yyyy-mm-dd'),5907);1 row insertedSQL> insert into t2 values(to_date('2006-12-27','yyyy-mm-dd'),6828);1 row insertedSQL> commit;Commit completeSQL> select d,d1,d2,v
2 from t1, (select d d1, lead(d-1,1,to_date('2999-12-31','yyyy-mm-dd')) over(order by d) d2, v from t2)
3 where d1(+)<=d and d<=d2(+);D D1 D2 V
----------- ----------- ----------- ----------
2006-12-1
2006-12-2
2006-12-3 2006-12-3 2006-12-7 4231
2006-12-4 2006-12-3 2006-12-7 4231
2006-12-5 2006-12-3 2006-12-7 4231
2006-12-6 2006-12-3 2006-12-7 4231
2006-12-7 2006-12-3 2006-12-7 4231
2006-12-8 2006-12-8 2006-12-12 6013
2006-12-9 2006-12-8 2006-12-12 6013
2006-12-10 2006-12-8 2006-12-12 6013
2006-12-11 2006-12-8 2006-12-12 6013
2006-12-12 2006-12-8 2006-12-12 6013
2006-12-13 2006-12-13 2006-12-16 2432
2006-12-14 2006-12-13 2006-12-16 2432
2006-12-15 2006-12-13 2006-12-16 2432
2006-12-16 2006-12-13 2006-12-16 2432
2006-12-17 2006-12-17 2006-12-18 1044
2006-12-18 2006-12-17 2006-12-18 1044
2006-12-19 2006-12-19 2006-12-19 7695
2006-12-20 2006-12-20 2006-12-24 4586D D1 D2 V
----------- ----------- ----------- ----------
2006-12-21 2006-12-20 2006-12-24 4586
2006-12-22 2006-12-20 2006-12-24 4586
2006-12-23 2006-12-20 2006-12-24 4586
2006-12-24 2006-12-20 2006-12-24 4586
2006-12-25 2006-12-25 2006-12-26 5907
2006-12-26 2006-12-25 2006-12-26 5907
2006-12-27 2006-12-27 2999-12-31 6828
2006-12-28 2006-12-27 2999-12-31 6828
2006-12-29 2006-12-27 2999-12-31 6828
2006-12-30 2006-12-27 2999-12-31 6828
2006-12-31 2006-12-27 2999-12-31 682831 rows selectedSQL>