Standard Deviation for SQLite

后端 未结 10 671
生来不讨喜
生来不讨喜 2020-12-14 08:05

I\'ve searched the SQLite docs and couldn\'t find anything, but I\'ve also searched on Google and a few results appeared.

Does SQLite have any built-in Standard Devi

10条回答
  •  囚心锁ツ
    2020-12-14 08:28

    You can calculate the variance in SQL:

    create table t (row int);
    insert into t values (1),(2),(3);
    SELECT AVG((t.row - sub.a) * (t.row - sub.a)) as var from t, 
        (SELECT AVG(row) AS a FROM t) AS sub;
    0.666666666666667
    

    However, you still have to calculate the square root to get the standard deviation.

提交回复
热议问题