Recommand · June 9, 2021 0

SQL Standard Deviation on multiple columns

I am trying to find the standard deviation of multiple columns. I am trying to get one more column which is the standard deviation of all the previous months.

Column a = Jan

Column b = Feb

Column c = Mar

Column d = Apr

Column e = May

Column a = Jan

This is what I have but I am getting an error when I run it. Any help would be much appreciated.

((SQRT(SQUARE((‘Jan’)-(AVG(‘Jan’)+(‘Feb’)+(‘Mar’)+(‘Apr’)+(‘May’))/5))/2) +

(SQRT(SQUARE((‘Feb’)-(AVG(‘Jan’)+(‘Feb’)+(‘Mar’)+(‘Apr’)+(‘May’))/5))/2) +

(SQRT(SQUARE((‘Mar’)-(AVG(‘Jan’)+(‘Feb’)+(‘Mar’)+(‘Apr’)+(‘May’))/5))/2) +

(SQRT(SQUARE((‘Apr’)-(AVG(‘Jan’)+(‘Feb’)+(‘Mar’)+(‘Apr’)+(‘May’))/5))/2) +

(SQRT(SQUARE((‘May’)-(AVG(‘Jan’)+(‘Feb’)+(‘Mar’)+(‘Apr’)+(‘May’))/5))/2) + ) AS ‘Std’