Subject | Re: [firebird-support] Re: Aggregate UDF? |
---|---|
Author | Michael Ludwig |
Post date | 2010-06-25T12:29:42Z |
Svein Erling schrieb am 25.06.2010 um 11:16 (-0000):
more efficient:
S = 'SELECT COUNT('||FIELD||'), AVG('||FIELD||') FROM '|| FROMCLAUSE;
EXECUTE STATEMENT S INTO :NORECORDS, :MYAVERAGE;
--
Michael Ludwig
> [...] isn't it an aggregate function that requires 'going through'Yes, exactly. Conceptually, it cannot be done in one pass.
> records twice (first finding the average and then how much each value
> deviates from this value)?
> CREATE PROCEDURE P_STDDEV (Great!
> FIELD VarChar(32),
> FROMCLAUSE VarChar(1900))
> returns (
> STDDEV Double Precision)
> S = 'SELECT COUNT('||FIELD||') FROM '|| FROMCLAUSE;You could combine these two into one statement, it would probably be
> EXECUTE STATEMENT S INTO :NORECORDS;
> S = 'SELECT AVG('||FIELD||') FROM '|| FROMCLAUSE;
> EXECUTE STATEMENT S INTO :MYAVERAGE;
more efficient:
S = 'SELECT COUNT('||FIELD||'), AVG('||FIELD||') FROM '|| FROMCLAUSE;
EXECUTE STATEMENT S INTO :NORECORDS, :MYAVERAGE;
--
Michael Ludwig