Re: median group function

From: Barry Drummond <barry_at_belmont.com>
Date: 1997/05/10
Message-ID: <Pine.SOL.3.96.970510101550.19418C-100000_at_belmt20>#1/1


Thanks for your quick response. I actually wrote a similar procedure due to the same limitation that you mention. However, sometimes I need to find the median of expressions (e.g. median(date1 - date2) where the dates may or may not be from the some tables. Due to the variables involved of possible joins, etc., I was hoping for something implemented in the same way as the Oracle internal aggregate functions so that median() could be used in as generalized a fashion as the others. I assume that these were written in a language other than pl/sql. Any ideas where to view the source code for the Oracle aggregates or to find this function in an underlying language?

By the way, when I wrote my procedure, I originally tried to set it up as a function as a SQL call. However, since I also used the DBMS_SQL package, I couldn't use the PRAGMA RESTRICT_REFERENCES necessary. I was able to set it up as a stored function to be used by othe PL/SQL code.

 -Barry

On Sat, 10 May 1997, Chrysalis wrote:

> Barry Drummond wrote:
> >
> > I'm looking for a median group function analogous to the Oracle group
> > functions (Count, Avg, etc.) which can be used in standard SQl statments.
> > As far as I can tell, PL/SQL allows only row functions to be built for use
> > in SQL.
> >
> > *snip*
> >
>
> Barry,
> The problem with the median is that it is a group function that
> requires analysis of a relation in a sequence. Since it is not
> implementable as a function, I have attached a stored procedure which
> can be used as a stand-alone mechanism to return the median value of an
> arbitrary column of an arbitrary table.
>
> Hope this helps.
>
> Chrysalis.
>
Received on Sat May 10 1997 - 00:00:00 CEST

Original text of this message