Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,34 @@
-- the minimal table
create table if not exists teststd (n double precision not null);
-- code modularity with view, we could have used a common table expression instead
create view vteststd as
select count(n) as cnt,
sum(n) as tsum,
sum(power(n,2)) as tsqr
from teststd;
-- you can of course put this code into every query
create or replace function std_dev() returns double precision as $$
select sqrt(tsqr/cnt - (tsum/cnt)^2) from vteststd;
$$ language sql;
-- test data is: 2,4,4,4,5,5,7,9
insert into teststd values (2);
select std_dev() as std_deviation;
insert into teststd values (4);
select std_dev() as std_deviation;
insert into teststd values (4);
select std_dev() as std_deviation;
insert into teststd values (4);
select std_dev() as std_deviation;
insert into teststd values (5);
select std_dev() as std_deviation;
insert into teststd values (5);
select std_dev() as std_deviation;
insert into teststd values (7);
select std_dev() as std_deviation;
insert into teststd values (9);
select std_dev() as std_deviation;
-- cleanup test data
delete from teststd;