Subject Re: [ib-support] AVG() on char field.
Author Martijn Tonies
Hi Arda,

One thing you could do is write an UDF that accepts text as a parameter and
returns a valid integer value. And perhaps -1 or so for non-valid integers
(POZITIVE). Then, do an AVG(myudffunction(column)) where
myudffunction(column) > -1 or so...




> Hi , I have a field that user enter data like;
>
> "POZITIVE",
> "5.34",
> "+++",
> "3.43",
> "7.00",
> "NEGATIVE",
>
> This field mainly stores numeric values, but users also enter data as
> characters as needed.
>
> Now I need to get the average of valid values. Obviously, I can't use
AVG()
> on these.
> I have done this. I get all the data to the client, and calculate the
> average by iterating the rows.
> Of course I know it's not the best way.
>
> Is it possible to do this with stored procedures?
> Is there any keywords that validate the numeric values in stored
procedures?
>
> Thank you.