Subject | RE: [firebird-support] Aggregate UDFs? |
---|---|
Author | Alan McDonald |
Post date | 2006-04-20T21:28:01Z |
> >>Alan McDonald wrote:no it can't - your first post just asked for aggregate functions, SUM()
> >>
> >>>>This is not something I need right now, but I'm curious: is
> it possible
> >>>>to add aggregate functions as UDFs?
> >>>>
> >>>>If not, are there any plans to add support for this?
> >>>
> >>>Do you mean SUM(), AVG() etc? if so then they are already
> >>>internal to the engine.
> >>
> >>Yes, I mean that KIND of function, but assume you'd want to return for
> >>example a concatenation of the values in a column:
> >>
> >>select Concat_UDF(ITEM)
> >>from STUFF
> >>group by CATEGORY
> >
> > select CATEGORY, sum(FIELDNAME) from TABLENAME group by CATEGORY
> >
> > If that's what you want then use it - it's there for you to use
>
> So sum(...) can actually concatenate char/varchar columns? I didn't know
> that.
AVG() MIN() MAX() are all aggregate functions.
Alan
>
> But that's not the point. Forget the example. Imagine, if you can, that
> you would need to do some kind of aggregate calculation that can't be
> done using any of the built-in aggregate functions. Could I write my own
> UDF to do it? (Adam already answered "no" btw.)
>
> Let's try with a different example: you have a table of numbers and you
> need to calculate the least common denominator (LCD):
>
> select LCD_UDF(NUMBER)
> from NUMBERS
>
> Kjell