Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8978781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:41:35+00:00 2026-06-15T19:41:35+00:00

Here’s how one of my tables are structured: id | group | val1 |

  • 0

Here’s how one of my tables are structured:

id | group | val1 | val2 | val3
1  | 1     | 22   | 23   | 60
2  | 1     | 40   | 60   | 80
3  | 2     | 50   | 5    | 70
4  | 2     | ...
5  | 2     | 
6  | 3     | 
...

In my PHP-document I’m calculating the standard deviation by using val1+val2+val3 etc. per row WHERE group equals the one I’m displaying.

Now I want to know, by using MySQL, what the standard deviation is per row and the average across a group. (row1stddev+row2stddev+...)/n

I’ve tried using subqueries, but all I can achieve is getting a single value. I think I have a lack of understanding how the the built in standard deviation functions in MySQL actually works with multiple values.

EDIT.
This is the two things I’m looking for:

id | group | stddev
1  | 1     | 21,65641
2  | 1     | 20
3  | 2     | 33,29164
4  | 2     | ...
5  | 2     | 
6  | 3     | 

And average by group (average of all stddev):

group | avg_stddev
1 | 20,828205
2 | …
3 | …

The point of this is that I want to know in which group the difference is largest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:41:36+00:00Added an answer on June 15, 2026 at 7:41 pm

    Since mysql native function STDDEV_POP accepts only column, you have to trick it by using temporary table, that will have one column with all values (that matters to standard deviation) in a row, for that use UNION ALL with 3 SELECTS, each for one meaningful column, and group it by row id.

    SELECT 
        id,
        STDDEV_POP(val) AS row_stddev 
    FROM (
        SELECT id, val1 AS val FROM stdev_table
        UNION ALL
        SELECT id, val2 AS val FROM stdev_table
        UNION ALL
        SELECT id, val3 AS val FROM stdev_table
    ) tmp0
    GROUP BY id
    

    you can also select additional column – group and create another temporary table to select average from it:

    SELECT 
        id_group,
        AVG(row_stddev) AS group_avg 
    FROM (
        SELECT 
            id, 
            id_group, 
            STDDEV_POP(val) AS row_stddev 
        FROM (
            SELECT id, id_group, val1 AS val FROM stdev_table
            UNION ALL
            SELECT id, id_group, val2 AS val FROM stdev_table
            UNION ALL
            SELECT id, id_group, val3 AS val FROM stdev_table
        ) tmp0
        GROUP BY id
    ) tmp1
    GROUP BY id_group
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is what I am currently doing. PHP echo's out the recent post in
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here's a dump of the stats provided my mod_pagespeed from one of my sites.
Here's the code require_once 'functions.php'; require_once 'cfg.php'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $db);
Here are the tables I have: Table A which has entries with item and
Here's the two scenarios. We are using a manually built xml soap request with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.