How can I take standard deviation in MYsql?

I have two columns containing two different timestamps for particular user. How can I calculate Standard deviation for this.

Is there any direct function available to perform this like sum() or avg()
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aleksandar BradarićSoftware DeveloperCommented:
You have the STDDEV() function... Not sure if that's what you need:
Look into the STD(), or  STDDEV_POP() aggregate functions in mysql.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

saini_erAuthor Commented:
Thanks guys for reply.....All of these methods are for finding standard deviation population where one value is randomly picked from table and then used as average..

I s there any function which can give regualr standard deviation whch is generally found by calculating exact mean
UmeshSenior Principal Technical Support EngineerCommented:
mysql supports STD() which is population standard deviation, and STDDEV_SAMP() which returns the sample standard deviation. Not sure but maybe the sample deviation is what you're looking for.

Alternatively you can do it manually using some variables. You can nest the aggregate functions in MySQL But I think if you get the average first and store it in a variable, you can do the rest. E.g. something like:

SELECT @ln_average := AVG(total) FROM yourtable;
SELECT (1/COUNT(total)) * SUM( POW(total - @ln_average,2) )  FROM yourtable;
"You can nest the aggregate functions in MySQL"

Sorry, you CAN'T nest the aggregate functions in MySQL.
saini_erAuthor Commented:
I don't  think there is any direct fuction . so I am going by mathematic expression and calculate result out of it

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.