Subject Statistical Data
Author Todd Brasseur
We are looking for a way to calculate some statistics.

The main statistic that we need is a 'median' (the middle occurance of
a list of values).

Ideally, we would have a function that we could use in stored
procedures that would work like avg, min, max, etc.:

Select Location, median(Ratio) From Sales Group By Location

Is the median something that would have to be added to Interbase (or
Firebird) itself (the same as avg, min, max, etc.) or is it something
that we could write ourselves? Does the SQL Standard include a median?

The only way I can think of doing it is to process data twice directly
in the stored procedure. Once to get the 'count' and then again with
an order by and counter to get the middle (or middle two) values.
This is a real pain because we need to calculate the median quite
often. It also makes things slow. It is so easy in Clipper as we
simply pass a function an array.

We also need to be able to calculate a 'square root' and 'logarithms'.

Any ideas would be greatly appreciated.

Todd