Getting average from 3 columns in MS SQL
Posted
by barbarian
on Stack Overflow
See other posts from Stack Overflow
or by barbarian
Published on 2010-03-15T16:27:06Z
Indexed on
2010/03/15
16:29 UTC
Read the original article
Hit count: 110
I have table with 3 columns(smallint) in MS SQL 2005.
Table Ratings
ratin1 smallint,
ratin2 smallint
ratin3 smallint
These columns can have values from 0 to 5
How to select average value of these fields, but only compare fields where value is greater then 0.
So if column values are 1,3,5 - average had to be 3 if values are 0,3,5 - average had to be 4
© Stack Overflow or respective owner