问题:计算某个数字列的累乘积。其操作方式与”计算累计和“相似,只是使用乘法而不是加法。
解决方案:作为例子,本解决方案中都计算职员工资的累乘积。虽然工资的累乘积没有多大用处,然后可以很容易地把该技巧用于其他更有用的领域。

select e.empno,e.ename,e.sal,
(select exp(sum(ln(d.sal)))
from emp d
where d.empno<=e.empno and e.deptno=d.deptno) as running_prod
from emp e
where e.deptno=10;

相关文章:

  • 2022-02-21
  • 2021-12-17
  • 2021-07-03
  • 2022-12-23
猜你喜欢
  • 2021-12-30
  • 2021-09-16
  • 2022-12-23
  • 2021-04-08
相关资源
相似解决方案