Sql 无重复的数组组合

Sql 无重复的数组组合,sql,postgresql,combinatorics,Sql,Postgresql,Combinatorics,我想从int[]中进行组合 {2,4,6,7,8,10,13,15,16,18}应给出以下结果: 2,4,6 2,4,7 2,4,8 ... 15,16,18 是否可以在不使用自定义函数的情况下编写仅查询的解决方案 with a as ( select i from unnest (array[2,4,6,7,8,10,13,15,16,18]) s(i) ) select * from a cross join a b cross join a c where

我想从int[]中进行组合

{2,4,6,7,8,10,13,15,16,18}应给出以下结果:

2,4,6
2,4,7
2,4,8
...
15,16,18
是否可以在不使用自定义函数的情况下编写仅查询的解决方案

with a as (
    select i
    from unnest (array[2,4,6,7,8,10,13,15,16,18]) s(i)
)
select *
from
    a cross join a b cross join a c
where
    a < b and b < c
order by a, b, c