SQLite Forum

SQLite3 Extension
Login
You can simplify this results a bit by remembering that avg(x) = sum(x) / count(x) to 

sort(sum(qty*qty) - sum(qty)*sum(qty)/count(*)) / count(*)

(and that final count(*) becomes (count(*)-1) if you are dealing with a sample instead of a full population.)