我知道你有多个主题涉及到这一点.但是,我找不到满足我需求的.我需要(按需)将深度表数据透视到宽输出表.这里的问题是我不能使用Pivot的聚合,因为它会占用输出中需要的响应.我已经找到了解决方案,但我认为这不是最好的,因为它需要无数的左连接才能工作.我已将所有尝试和说明包括在内如下:
-- Sql Server 2008 db. -- Deep table structure (not subject to modification) contains name/value pairs with a userId as -- foreign key. In many cases there can be MORE THAN ONE itemValue given by the user for the -- itemName such as if asked their race, can answer White + Hispanic, etc. Each response is stored -- as a seperate record - this cannot currently be changed. -- Goal: pivot deep data to wide while also compressing result …