I got a simple SELECT query:

**SELECT id
FROM myTable
WHERE id <= x;**

and the results are:

1

2

3

4

.

.

x

and what i need is the combinations of (x-1), (x-2), …, 2

Let’s say x = 4.

The combinations of 3 and 2 records would be:

1,2,3

1,2,4

1,3,4

2,3,4

AND

1,2

1,3

1,4

2,3

2,4

3,4

Anyone has any idea of how this is possible?

PS: I’m using ColdFusion, but try any language serves you and I’ll translate it. :glasses:

Thanks