use*_*015 2 sql t-sql sql-server permutation
我有X个值通过CSV传递到表中 - 所以我将99315,99316,99223分成一个列临时表 - 将CSV中的每个值分成一行.
我需要做的是成对地获取每个值的排列 - 所以 - 例如:
Col1 Col2
99315 99316
99315 99223
99316 99315
99316 99223
99223 99315
99223 99316
Run Code Online (Sandbox Code Playgroud)
select t1.col1, t2.col1 col2
from mytable t1
cross join mytable t2
Run Code Online (Sandbox Code Playgroud)
如果你想排除类似的值添加
where t1.col1 <> t2.col1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
68 次 |
| 最近记录: |