Subject | Re: Register standard deviation as a stored procedure. |
---|---|
Author | tankinguard |
Post date | 2009-07-30T11:50:31Z |
When remaking by the method which you taught, I have got the result.
But it does not become still like MySQL. mmm...
-----------------------------------------
SET TERM !!;
CREATE OR ALTER PROCEDURE STDEV(sTable CHAR(31), sField CHAR(31))
RETURNS (nResult DOUBLE PRECISION) AS
BEGIN
EXECUTE STATEMENT 'SELECT SQRT((COUNT(' || sField || ') *
SUM(POWER(' || sField || ', 2)) - POWER(SUM(' || sField || '), 2))
/ (COUNT(' || sField || ') * (COUNT(' || sField || ') - 1))) FROM ' || sTable
INTO :nResult;
END !!
SET TERM;!!
-----------------------------------------
EXECUTE PROCEDURE STDEV('table', 'score');
-----------------------------------------
But it does not become still like MySQL. mmm...
-----------------------------------------
SET TERM !!;
CREATE OR ALTER PROCEDURE STDEV(sTable CHAR(31), sField CHAR(31))
RETURNS (nResult DOUBLE PRECISION) AS
BEGIN
EXECUTE STATEMENT 'SELECT SQRT((COUNT(' || sField || ') *
SUM(POWER(' || sField || ', 2)) - POWER(SUM(' || sField || '), 2))
/ (COUNT(' || sField || ') * (COUNT(' || sField || ') - 1))) FROM ' || sTable
INTO :nResult;
END !!
SET TERM;!!
-----------------------------------------
EXECUTE PROCEDURE STDEV('table', 'score');
-----------------------------------------