n C r ?with TableA as( select col = 1 union all select col = 2 union all select col = 3 union all select col = 4 union all select col = 5)select col, row_no as combifrom ( select row_no = row_number() over (order by c1.col, c2.col, c3.col), col1 = c1.col, col2 = c2.col, col3 = c3.col from TableA c1 inner join TableA c2 on c1.col <> c2.col inner join TableA c3 on c1.col <> c3.col and c2.col <> c3.col ) d unpivot ( col for cols in (col1, col2, col3) ) p
KH[spoiler]Time is always against us[/spoiler]