Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> SQL - Computing average for multiple columns
OK, maybe I'm OVERTHINKING this, but is there a way to get the average
of multiple columns, factoring in that some of the data may be null?
As far as I can tell, I can't do an 'average(col1+col2+col3)'. I know
(col1+col2+col3)/3 would work, but if col3 is null, then it really
should be a divide by 2. I somehow got into using nvl and decode to
assist, but it still doesn't account for a scenario where all three
columns are null for a variable, since I still get a 'divide by zero'
error for that.
Thanks for any help. Received on Wed Sep 26 2001 - 15:50:28 CDT
![]() |
![]() |