我正在尝试构建一个动态数据透视表,它基本上按月显示客户的订阅量。枢轴的动态部分正常工作,但生成的每个客户ID有多个不相同的行,我不知道为什么。公平的警告,我对这整个SQL事情都很陌生,所以我的代码可能完全混乱,为此我很抱歉
SELECT [Customer ID], [Jan 1 2013 12:00AM],[Feb 1 2013 12:00AM],[Mar 1 2013 12:00AM],[Apr 1 2013 12:00AM],[May 1 2013 12:00AM],[Jun 1 2013 12:00AM],[Jul 1 2013 12:00AM],[Aug 1 2013 12:00AM],[Sep 1 2013 12:00AM],[Oct 1 2013 12:00AM],[Nov 1 2013 12:00AM],[Dec 1 2013 12:00AM],[Jan 1 2014 12:00AM],[Feb 1 2014 12:00AM],[Mar 1 2014 12:00AM],[Apr 1 2014 12:00AM],[May 1 2014 12:00AM],[Jun 1 2014 12:00AM],[Jul 1 2014 12:00AM],[Aug 1 2014 12:00AM],[Sep 1 2014 12:00AM],[Oct 1 2014 12:00AM],[Nov 1 2014 12:00AM],[Dec 1 2014 12:00AM],[Jan 1 2015 12:00AM],[Feb 1 2015 12:00AM],[Mar 1 2015 12:00AM],[Apr 1 2015 12:00AM],[May 1 2015 12:00AM],[Jun 1 2015 12:00AM],[Jul 1 2015 12:00AM],[Aug 1 2015 12:00AM],[Sep 1 2015 12:00AM],[Oct 1 2015 12:00AM],[Nov 1 2015 12:00AM],[Dec 1 2015 12:00AM],[Jan 1 2016 12:00AM],[Feb 1 2016 12:00AM]
INTO [Service Contract Data].[dbo].[Pivot_Results] FROM [Service Contract Data].[dbo].[filtered_data]
PIVOT(SUM([Service Contract Data].[dbo].[filtered_data].[Subscription Amount])
FOR [Month] IN ([Jan 1 2013 12:00AM],[Feb 1 2013 12:00AM],[Mar 1 2013 12:00AM],[Apr 1 2013 12:00AM],[May 1 2013 12:00AM],[Jun 1 2013 12:00AM],[Jul 1 2013 12:00AM],[Aug 1 2013 12:00AM],[Sep 1 2013 12:00AM],[Oct 1 2013 12:00AM],[Nov 1 2013 12:00AM],[Dec 1 2013 12:00AM],[Jan 1 2014 12:00AM],[Feb 1 2014 12:00AM],[Mar 1 2014 12:00AM],[Apr 1 2014 12:00AM],[May 1 2014 12:00AM],[Jun 1 2014 12:00AM],[Jul 1 2014 12:00AM],[Aug 1 2014 12:00AM],[Sep 1 2014 12:00AM],[Oct 1 2014 12:00AM],[Nov 1 2014 12:00AM],[Dec 1 2014 12:00AM],[Jan 1 2015 12:00AM],[Feb 1 2015 12:00AM],[Mar 1 2015 12:00AM],[Apr 1 2015 12:00AM],[May 1 2015 12:00AM],[Jun 1 2015 12:00AM],[Jul 1 2015 12:00AM],[Aug 1 2015 12:00AM],[Sep 1 2015 12:00AM],[Oct 1 2015 12:00AM],[Nov 1 2015 12:00AM],[Dec 1 2015 12:00AM],[Jan 1 2016 12:00AM],[Feb 1 2016 12:00AM])) AS PVTTable
@DynamicPivotQuery返回
document.getElementbyId