Are you sur you don't want a moving windows
(stddev on 0 to 50 , then stdev on 1 to 51)..
If you don't want moving windows your query would look like
DROP TABLE IF EXISTS your_data;
CREATE TABLE your_data AS
SELECT s as gid , random() as your_data_value
FROM generate_series(1,10000) as s ;
SELECT min(gid) as min_gid, max(gid) as max_gid, stddev(your_data_value) as your_stddev
FROM your_data
GROUP BY (gid-1)/50
ORDER BY min_gid ASC
Please note that "min(gid) as min_gid, max(gid) as max_gid" and "ORDER BY min_gid ASC" are just there to help you understand the result
Cheers,Rémi-C
2015-01-22 16:49 GMT+01:00 David G Johnston <david.g.johnston@xxxxxxxxx>:
Pierre Hsieh wrote
Integer division> Hi
>
> This table just has a column which type is integer. There are one million
> data in this table. I wanna calculate standard deviation on each 50 data
> by
> order. It means SD1 is from data 1 to data 50, SD2 is from data 51 to
> 100.... Is there anyone who can give me some suggestions? Thanks
>
> Pierre
David J.
--
View this message in context: http://postgresql.nabble.com/how-to-calculate-standard-deviation-from-a-table-tp5835031p5835042.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general