我有一个包含两列的表,它们都包含整数值,如下所示:
DocumentUpId RelatedDocId
31608768 31624333
31608768 31624334
31618133 31618117
我正在尝试将它们合并成一个列,如下所示:
DocumentUpId
31608768
31608768
31618133
31624333
31624334
31624334
我试过这个:
select rel_CTE.DocumentUpId + rel_CTE.DocumentDownId as 'RelatedDocId'
into #temprelations
from RelationsCTE rel_CTE
但它给了我值的串联(在这种情况下很好地求和),所以这可能吗?
最佳答案
联合所有
select rel_CTE.DocumentUpId as 'RelatedDocId' from RelationsCTE
union all
select rel_CTE.DocumentDownId from RelationsCTE
关于sql - 将两个sql列合并为一个列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38975864/