In a different question, I asked about all possible 3-way combinations of a table, assuming that there are 3 articles. In this question, I would like to further extend the problem to return all n-way combinations of a table with n distinct articles. One article can have multiple suppliers. My goal is to have groups of combinations with each group having each article.
Below is a sample table but keep in mind that there could be more than those 3 articles.
+---------+----------+
| Article | Supplier |
+---------+----------+
| 4711 | A |
| 4712 | B |
| 4712 | C |
| 4712 | D |
| 4713 | C |
| 4713 | E |
+---------+----------+
For the example above, there would be 6 combination pairs possible with 18 datasets. Below is how the solution for the example above is supposed to look like:
+----------------+---------+----------+
| combination_nr | article | supplier |
+----------------+---------+----------+
| 1 | 4711 | A |
| 1 | 4712 | B |
| 1 | 4713 | C |
| 2 | 4711 | A |
| 2 | 4712 | B |
| 2 | 4713 | E |
| 3 | 4711 | A |
| 3 | 4712 | C |
| 3 | 4713 | C |
| 4 | 4711 | A |
| 4 | 4712 | D |
| 4 | 4713 | E |
| 5 | 4711 | A |
| 5 | 4712 | D |
| 5 | 4713 | C |
| 6 | 4711 | A |
| 6 | 4712 | D |
| 6 | 4713 | E |
+----------------+---------+----------+
I am asking this in a different question because in the other question I have not specified that I need this to be dynamic and not only the 3 articles from above. Here you can find the old question.