This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / oracle 里有啥函数,或者是组合,使 a-b 正数返回 1,负数返回 -1
-vetra(多泡泡);
2010-6-23
(#6143142@0)
-
CASE WHEN a> b THEN 1 ELSE -1 END ?
-c1xwy(洪兴罩俺去战斗);
2010-6-23
(#6143153@0)
-
decode
-f001(夲哥);
2010-6-23
(#6143172@0)
-
不用函数也可以, 把这放到SELECT里就可以: (CASE WHEN cola-colb>0 THEN 1 ELSE -1)
-natureguy(枫);
2010-6-23
(#6143174@0)
-
这个最好,写出来容易被人理解!!!虽然执行起来速度不快
-vetra(多泡泡);
2010-6-23
(#6143311@0)
-
select (a-b)/abs(a-b) from dual
-alwaystobe(给点阳光就灿烂);
2010-6-23
(#6143184@0)
-
Mine is best solution, right?
-alwaystobe(给点阳光就灿烂);
2010-6-23
(#6143195@0)
-
如果a-b = 0 就杯具了
-binghongcha76(一只大猫);
2010-6-23
(#6143209@0)
-
所以,还是case when 比较保险
-binghongcha76(一只大猫);
2010-6-23
(#6143210@0)
-
如果a,b相等,你的系统就爆炸了
-oneandone(1+1);
2010-6-23
(#6143215@0)
-
hehe, I was using that solution before, just want to see whoelse has better one.
-vetra(多泡泡);
2010-6-23
(#6143217@0)
-
改进一点:select decode((a-b), 0, 0, (a-b)/abs(a-b)) from dual
-copperbean(允执其中);
2010-6-23
(#6143223@0)
-
Yes. This one : select decode((a-b), 0, 0, (a-b)/abs(a-b)) from dual ---- Best answer
-alwaystobe(给点阳光就灿烂);
2010-6-23
(#6143241@0)
-
握个手,合作愉快。泡泡呢?也不上来谢一声!
-copperbean(允执其中);
2010-6-23
(#6143263@0)
-
你没有比我 好多少啊, I want to see who is more SMART
-vetra(多泡泡);
2010-6-23
(#6143282@0)
-
smarter
-wincity(toad 会英文的红卫兵);
2010-6-23
(#6143295@0)
-
SMARTER, please.哼,跟你较上劲了。
-copperbean(允执其中);
2010-6-23
{18}
(#6143296@0)
-
比我 smarter 又赢不了世界,哼哼
-vetra(多泡泡);
2010-6-23
(#6143320@0)
-
非得搞个 can not divide by zero error 出来不可。 请各位做除法的检查一下, 如果 a=b 怎么办?
-zzhang(zz);
2010-6-23
(#6143801@0)
-
谢谢所有回答的童鞋,回家了!
-vetra(多泡泡);
2010-6-23
(#6143313@0)
-
泡泡近来可好?是 sign().
-newbuddie(就要登陆);
2010-6-24
(#6145262@0)
-
这才是最好的! 我当初学的时候,就不知道这个函数意义何在
-vetra(多泡泡);
2010-6-25
(#6145791@0)