我在那里的数据将显示这样一个表中的数据:如何列转换为行
DatePeriod Good Fair Poor NotCategorised NotTested GoodPercentage FairPercentage PoorPercentage NotCategorisedPercentage NotTestedPercentage
Feb-13 4 0 0 0 60 6.25 0 0 0 93.75
而对于这一次我已经使用UNPIVOT书面查询。
Select DatePeriod,Legend FROM
(
select DatePeriod,Good,Fair,Poor,NotCategorised,NotTested,GoodPercentage,
FairPercentage,poorPercentage,NotCategorisedPercentage,NotTestedPercentage from #cte
)P
UNPIVOT(Legend FOR #CTE IN (Good,Fair,Poor,NotCategorised,NotTested))AS UNPVT;
我没有得到所需要的输出
我的结果集必须这样的:
year Legend percent count
Dec-12 Good 13.89 35
Dec-12 Fair 0 0
Dec-12 Poor 0 0
Dec-12 NC 0 0
Dec-12 NoData 86.11 217
我建议最好的方式。
它有助于提供表定义,和你实际看到的结果。我们输入的越少,为了测试更快,您将得到答案。 – BlackICE