Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: aggregate function

Re: aggregate function

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Wed, 20 Dec 2000 22:11:59 -0000
Message-ID: <977350459.11325.0.nnrp-13.9e984b29@news.demon.co.uk>

It is generally possible - but there is a limitation that makes the specific example fail.

You can write a function to do:

select f(col1, col2, col3), col1, col2,col3 from table
group by col1, col2, col3;

The function simply has to embed a

    select {requirements} from table
    where col1 = parm1
    and col2 = parm2
    and col3 = parm3

It seems to work quite efficiently as the function is called AFTER the group by,
i.e. just once for each combination of
col1, col2, col3.

--
Jonathan Lewis
Yet another Oracle-related web site:  http://www.jlcomp.demon.co.uk

Practical Oracle 8i:  Building Efficient Databases

Publishers:  Addison-Wesley
See a first review at:
http://www.ixora.com.au/resources/index.htm#practical_8i
More reviews at: http://www.jlcomp.demon.co.uk/book_rev.html



Alex Filonov wrote in message <91r5up$ldk$1_at_nnrp1.deja.com>...

>As far as I know, you can't.
>
>In article <91qgc1$16n$1_at_nnrp1.deja.com>,
> slezakp_at_my-deja.com wrote:
>> Can one write an aggregate function in Oracle 8.1.6?
>>
>> Example: normal sum
>>
>> select sum(tools) from powertools;
>>
>> I want to be able to do:
>>
>> select mysum(tools) from powertools.
>>
>> Note that mysum will not know what table or column ahead of time.
>>
>> Thanks,
>> Paul
>>
>> Sent via Deja.com
>> http://www.deja.com/
>>
>
>
>Sent via Deja.com
>http://www.deja.com/
Received on Wed Dec 20 2000 - 16:11:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US