ID QTY
1 2
2 4
3 6
4 5
要求能够得到QTY字段的乘积2*4*6*5,

运用一下数学知识, 可以这样简化:

a * b * c = power(10, log(10, a) + log(10, b) + log(10, c)


Select power(10, Sum(Log(10, qty))) From t



scott@O9I.US.ORACLE.COM> drop table t;

Table dropped.

scott@O9I.US.ORACLE.COM> create table t (id number, qty number);

Table created.

scott@O9I.US.ORACLE.COM> insert into t values(1, 2);

1 row created.

scott@O9I.US.ORACLE.COM> insert into t values(2, 4);

1 row created.

scott@O9I.US.ORACLE.COM> insert into t values(3, 6);

1 row created.

scott@O9I.US.ORACLE.COM> insert into t values(4, 5);

1 row created.

scott@O9I.US.ORACLE.COM> commit;

Commit complete.

scott@O9I.US.ORACLE.COM> Select power(10, Sum(Log(10, qty))) From t
2 ;

POWER(10,SUM(LOG(10,QTY)))
--------------------------
240


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/756652/viewspace-242356/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/756652/viewspace-242356/

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐