I have a table data where the data will be shown like this :
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
And for this one I have written query using 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;
I am not getting the required output
my result set need to be like this :
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
Suggest me the best way.