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

Home -> Community -> Usenet -> c.d.o.misc -> SQL - Computing average for multiple columns

SQL - Computing average for multiple columns

From: Quincy Smith <QuincyRS_at_hotmail.com>
Date: 26 Sep 2001 13:50:28 -0700
Message-ID: <770866f7.0109261250.a7e0b7@posting.google.com>


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

Original text of this message

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