The most elegant way to generate permutations in SQL server

后端 未结 10 1370
面向向阳花
面向向阳花 2020-11-29 07:00

Given a the following table:

Index | Element
---------------
  1   |    A
  2   |    B
  3   |    C
  4   |    D

We want to generate all th

10条回答
  •  再見小時候
    2020-11-29 07:34

    Am I correctly understanding that you built Cartesian product n x n x n x n, and then filter out unwanted stuff? The alternative would be generating all the numbers up to n! and then using factorial number system to map them via element encoding.

提交回复
热议问题