0
这是我的源表(pivot_dummy):SQL支点 - 如何获得列之间的所有可能的组合摆动
,我需要通过Parameter_type转动,但需要Parameter_val的之间的所有可能的组合。把它做这样
什么我用这个代码:
SELECT nct_id, [Asset],[Indication], rowid
FROM (SELECT nct_id,Parameter_val,parameter_type, rowid
FROM (Select *,
Row_Number() Over (Partition By nct_id,Parameter_type ORDER BY nct_id) RowId
from [dbo].[pivot_dummy]
) a
) s
Pivot (
max(parameter_val)
for Parameter_type in ([Asset], [Indication])
) as pivottable
但是这个代码的结果如下:
是否有人可以帮忙吗?
嗨戈登,这工作很好!非常感谢! –
嗨戈登,当只有两列(资产和指示)时,这解决了我的问题。但实际上,我有7列需要进行调整,并且还可以根据NCTID找到所有可能的组合,可能的解决方案是什么?我还应该考虑摆动吗? –
@AnkurBansal。 。 。只能回答你所问的问题。如果您有其他问题,请将其作为*新问题。 –