Wednesday, January 29, 2014

How can I calculate % Change in Pivot using CTE ?

If you want to Round to the nearest integer (that is -20.45 becomes -20 and 4.91 becomes 5), then


Cast(Round(([2012]-[2011])/Cast([2011] As decimal(9,2))*100, 0) As int)


If you want to truncate the decimal (that is -20.45 becomes -20 and 4.91 becomes 4), then


Cast(([2012]-[2011])/Cast([2011] As decimal(9,2))*100 As int)


Tom


No comments:

Post a Comment