首页 > 数据库 > Oracle > oracle,使用model补全中间空缺数字
with t as(select 2 n,'tom' name from dual union all select 4,'tom' from dual union all select 7,'tom' from dual
union all select 1,'jerry' from dual union all select 3,'jerry' from dual)
select name,n,f
from t
model
return updated rows
/* partition by(name)*/
dimension by(name,n)
measures(1 f)
rules(
f[for (name,n) in (select name,minn+level-1 from(select name,min(n) minn,max(n) maxn from t group by name) connect by level<=maxn-minn+1 and prior name=name and prior sys_guid() is not null)]
=presentv(f[cv(),cv()],f[cv(),cv()],0)
)
order by 1,2
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30363279/viewspace-2645218/ ,如需转载,请注明出处,否则将追究法律责任。