原表T
a b c d e
1 2 4 5 9
1 2 8 4 5
3 3 2 5 6想求出每一行的最值,即
a b c d e max
1 2 4 5 9 9
1 2 8 4 5 8
3 3 2 5 6 6哪位大侠给出出招啊,我想到的方法
1:行列转置,然后用max函数求,再转置回去
2:用perl,将表数据导出给数组,取出每行的最值,再入会库中
大侠们给解决下吧
a b c d e
1 2 4 5 9
1 2 8 4 5
3 3 2 5 6想求出每一行的最值,即
a b c d e max
1 2 4 5 9 9
1 2 8 4 5 8
3 3 2 5 6 6哪位大侠给出出招啊,我想到的方法
1:行列转置,然后用max函数求,再转置回去
2:用perl,将表数据导出给数组,取出每行的最值,再入会库中
大侠们给解决下吧
from t
Routine (greatest) can not be resolved
你的能执行?
set t.max=t.a;
update t
set t.max=decode(max>b,max,b);
update t
set t.max=decode(max>c,max,c);
update t
set t.max=decode(max>d,max,d);
update t
set t.max=decode(max>e,max,e);
A B C D E MAX
--------------------- --------------------- --------------------- --------------------- --------------------- ---------------------
1 12 3 2 12
3 23 5 3 6
32 64 6 8 32
23 66 87 34 23
SQL>
SQL> update T
2 set t.max=t.a;
4 rows updated
SQL> update t
2 set t.max=decode(sign(t.max-b),1,t.max,b);
4 rows updated
SQL> update t
2 set t.max=decode(sign(t.max-c),1,t.max,c);
4 rows updated
SQL> update t
2 set t.max=decode(sign(t.max-d),1,t.max,d);
4 rows updated
SQL> update t
2 set t.max=decode(sign(t.max-e),1,t.max,e);
4 rows updated
SQL> SELECT * FROM t;
A B C D E MAX
--------------------- --------------------- --------------------- --------------------- --------------------- ---------------------
1 12 3 2 12 12
3 23 5 3 6 23
32 64 6 8 32 64
23 66 87 34 23 87
SQL>