Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: AVG across columns
I said ...
> Tim B says...
>> how about something like this, using nvl and nvl2?
>> (not tested):
>> select
>> row_id,
>> nvl(v1, 0) valv1,
>> nvl2(v1, 1, 0) countv1,
>> nvl(v2, 0) valv2,
>> nvl2(v2, 1, 0) countv2 ,
>> (valv1 + valv2)/(countv1 + countv2) ... etc.
>
> Tested using small sample and yes, it works. Totally overlooked NVL2.
>
> Thanks heaps!
>
> Now trying with real data ...
.. and sucessful there too. Geoff M owes Tim B one big time.
GM Received on Mon Aug 06 2007 - 18:50:27 CDT
![]() |
![]() |