How to select standard deviation within a row? (in SQL - or R :)

前端 未结 4 1244
时光取名叫无心
时光取名叫无心 2020-12-21 04:41

I wonder whether there is a way to select the standard deviation from several integer fields in MySQL within the same row. Obviously, if I use



        
4条回答
  •  独厮守ぢ
    2020-12-21 05:17

    for simplicity, assume you have n columns, named A, B, C .... :

    SELECT SQRT(  
      (A*A + B*B + C*C + ...)/n  - (A+B+C+...)*(A+B+C+...)/n/n) AS sd
      FROM table;
    

提交回复
热议问题