我有一个特殊的情况。我试图在 T-SQL 中的动态数据透视的帮助下使用 grid1 来实现 grid2 结果,这将充当存储过程,用于将其调用到我的 asp.net Web 表单中。但是,由于 grid2 中的列名相同,我的查询会抛出错误,指出列名被多次使用。无论如何要在不更改 grid2 列名的情况下调用 sp?尝试了动态枢轴中的功能 STUFF & QUOTENAME 但效果不佳。
任何帮助将非常感激。
附加网格的图像以防它不可见。
非常感谢。
Grid1 - Actual View.
UID GeoBusinessType GeoCountry UIDCountry UIDBusinessType Revenue
123456 Commercial United States United States Commercial $100
123456 Consumer United States United States Consumer $150
123456 Consumer United States United States Consumer $200
678901 Commercial United States United States Commercial $250
678901 Commercial United States United States Commercial $300
123246 Consumer United States United States Consumer $350
123246 Consumer France France Consumer $400
123246 Commercial France France Commercial $450
123246 Commercial France France Commercial $500
246488 Consumer France France Consumer $550
246488 Consumer France France Consumer $600
246488 Consumer France France Consumer $650
246488 Consumer France France Consumer $700
492968 Consumer France France Consumer $750
492968 Consumer Germany Germany Consumer $800
492968 Consumer Germany Germany Consumer $850
985929 Consumer Germany Germany Consumer $900
985929 Consumer Germany Germany Consumer $950
985929 Commercial Germany Germany Commercial $1,000
985929 Commercial Germany Germany Commercial $1,050
197189 Consumer Germany Germany Consumer $1,100
197189 Consumer India India Consumer $1,150
197189 Commercial India India Commercial $1,200
197189 Commercial India India Commercial $1,250
Grid2 - Desired view.
GeoBusinessType GeoCountry UIDCountry UIDBusinessType
UID Commercial Consumer United States France Germany India United States France Germany India Commercial Consumer Revenue
123456 GeoBusinessType GeoBusinessType GeoCountry NULL NULL NULL UIDCountry NULL NULL NULL UIDBusinessType UIDBusinessType 450
678901 GeoBusinessType NULL GeoCountry NULL NULL NULL UIDCountry NULL NULL NULL UIDBusinessType NULL 550
123246 GeoBusinessType GeoBusinessType GeoCountry GeoCountry NULL NULL UIDCountry UIDCountry NULL NULL UIDBusinessType UIDBusinessType 1700
246488 GeoBusinessType NULL NULL GeoCountry NULL NULL NULL UIDCountry NULL NULL UIDBusinessType NULL 2500
492968 NULL GeoBusinessType NULL GeoCountry GeoCountry NULL NULL UIDCountry UIDCountry NULL NULL UIDBusinessType 2400
985929 GeoBusinessType NULL NULL NULL GeoCountry NULL NULL NULL UIDCountry NULL UIDBusinessType NULL 3900
197189 GeoBusinessType GeoBusinessType NULL NULL NULL GeoCountry NULL NULL NULL UIDCountry UIDBusinessType UIDBusinessType 4700