RE: calculation of averages

RE: calculation of averages

 

  


What is your full query? And what exactly are you looking for?

The equivalent of
select avg(sum(vsize(text_info))) from detail_info group by id;

gives me a single number, which is the average of all the sums.

select avg(vsize(text_info)) from detail_info group by id;

gives me the average size of text_info for each id.

select avg(vsize(text_info)) from detail_info; -- no group by

gives me the average size of text_info regardless of id.

HTH,
-Chris

> -----Original Message-----
> From: John DeUnger
> Sent: Thursday, March 28, 2002 6:49 PM
> To: LazyDBA.com Discussion
> Subject: calculation of averages
>
>
> Dear Gurus:
> Need some help in doing a calculation.
> I have parent-child tables.
> I want to figure out the total length of the text_info column
> for a record.
> The master table has one record - and detail info contains
> the children.
> I can have many children using the id, and seq columns.
>
> detail_info (child table) detail_master
>
> id varchar2(30) id
> seq number date
> text_info varchar2(2000) address.... (other stuff)
> date
>
> if I do a -
>
> select sum(vsize(text_info) from detail_info
> group by id.
>
> This will give me id sum(vsize) of the records for the id.
> 001 458 (1 record)
> 002 88888 (3 records)
>
> I will get the count of the all the records for each id.
>
> Then what I am trying to do is take the sum for each id and do an
> average to show the an average number.
>
> I can't seem to do this with an avg(sum(vsize(text_detail)....
> Is my use of the group by id causing a problem ? Maybe it's cause
> the text_info field is varchar2 ???
>
> How can I accomplish this ?
>
> Thanks.
> Steff DeUnger
>

LEGAL NOTICE - Unless expressly stated otherwise, this message is
confidential and may be privileged. It is intended for the addressee(s)
only. Access to this e-mail by anyone else is unauthorized. If you are not
an addressee, any disclosure or copying of the contents or any action taken
(or not taken) in reliance on it is unauthorized and may be unlawful. If you
are not an addressee, please inform the sender immediately.
Oracle LazyDBA home page