【问题标题】:Combinatorics in SQL: "Choose" FunctionSQL 中的组合:“选择”函数
【发布时间】:2015-01-09 21:19:39
【问题描述】:

使用 PLSQL Developer 并为n choose k 寻找一个简单的函数。我只是无法通过 Google 找到它,因为当我搜索“选择”时,我不断获得有关 CASE 的信息。谢谢!

【问题讨论】:

  • ...还是我必须自己创建?

标签: sql oracle plsql oracle11g plsqldeveloper


【解决方案1】:

基于knowledge found on Wikipedia

function combination(n in integer, k in integer)
    return integer
is
    l_result integer;
begin
    for i in 1..k loop
        l_result := l_result * (n-i+1) / k;
    end loop;
    return l_result;
end;
/

享受吧。

【讨论】:

  • 是的,我看到我已经走自定义函数路线了。谢谢。
猜你喜欢
  • 1970-01-01
  • 2020-05-09
  • 2018-05-12
  • 1970-01-01
  • 2010-11-19
  • 1970-01-01
  • 2014-01-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多