数据格式:
1 0.1
2 0.2
3 0.3
4 0.4
5 0.5结果:
0.5 + (1-0.5)*0.4
+ (1-0.5)*(1-0.4)*0.3
+ (1-0.5)*(1-0.4)*(1-0.3)*0.2
+ (1-0.5)*(1-0.4)*(1-0.3)*(1-0.2)*0.1
不知道怎么在oracle中实现,谢谢大侠!
1 0.1
2 0.2
3 0.3
4 0.4
5 0.5结果:
0.5 + (1-0.5)*0.4
+ (1-0.5)*(1-0.4)*0.3
+ (1-0.5)*(1-0.4)*(1-0.3)*0.2
+ (1-0.5)*(1-0.4)*(1-0.3)*(1-0.2)*0.1
不知道怎么在oracle中实现,谢谢大侠!
2 select 1 id, 0.1 num from dual union all
3 select 2 id, 0.2 num from dual union all
4 select 3 id, 0.3 num from dual union all
5 select 4 id, 0.4 num from dual union all
6 select 5 id, 0.5 num from dual)
7 SELECT regexp_replace(regexp_replace(sys_connect_by_path(to_char(num, 'fm0.99'), '*'),
8 '([0-9]+.[0-9]+)\*',
9 '(1-\1)*'),'^[\*]','+')
10 FROM t
11 START WITH id = (SELECT MAX(id) FROM t)
12 CONNECT BY PRIOR id - 1 = id;
REGEXP_REPLACE(REGEXP_REPLACE(
--------------------------------------------------------------------------------
+0.5
+(1-0.5)*0.4
+(1-0.5)*(1-0.4)*0.3
+(1-0.5)*(1-0.4)*(1-0.3)*0.2
+(1-0.5)*(1-0.4)*(1-0.3)*(1-0.2)*0.1
SQL>
REGEXP_REPLACE 函数是oracle的哪个版本存在的啊?我这边是9i