Subject Re: [firebird-support] Calculating median value on a large table
Author Alexandre Benson Smith
At 12:51 13/01/2004 +1100, you wrote:

>Using FirebirdCS-
>Suppose I have a table with 30 million records as follows:
>create table (
> name char(10),
> age integer
>Can anybody suggest an efficient method of calculating the median age
>(not average) ?

Hi Bill,

FB does not have statistical functions... I use to do it on the client side
(using Crystal Reports), but since I have to fetch all rows, this will be a
time consuming task, so I use to do other things just for cosmetics... like
put graphics, show top/most common values, etc.

I think the fastest way will be in a SP, in SP will be MUCH faster than
fetch all record to the client... but some statistical functions will need
to populate intermediate/temporary tables, so this could be a boring task
to code... :-(


Alexandre Benson Smith
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004

[Non-text portions of this message have been removed]