Subject Re: [firebird-support] Re: Register standard deviation as a stored procedure.
Author Aage Johansen
tankinguard wrote:
> 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');
> -----------------------------------------
>

Does it help if you
a) include a SUSPEND, and b) call it with something like
select NRESULT
from STDEV
where STABLE = 'table'
and SFIELD = 'score'

I haven't read your code carefully, so ...

--
Aage J.