问题
I would like to make combinations out from an int[]
{2,4,6,7,8,10,13,15,16,18} should give following results:
2,4,6
2,4,7
2,4,8
...
15,16,18
Is it possible to write query only solution without using custom functions?
回答1:
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
来源:https://stackoverflow.com/questions/16899760/array-combinations-without-repetition