return all possible combinations of values in columns in SQL
How do I return a list of all combinations of values in 4 columns so that
they are new rows in Microsoft SQL Server 2012 e.g.
c1 c2 c3 c4
1 a g x
2 b h y
and turn it into
c1 c2 c3 c4
1 a g x
1 a g y
1 a h x
1 a h y
and so on having all (2X2X2X2)=16 rows in 4 columns
Similar solution for 2 columns has been answered on
Return all possible combinations of values on columns in SQL
I need the solution for 4 columns
No comments:
Post a Comment