I have a mysql database field named "numbers" in which there are 10 records with numbers from 0 to 10.
I would like to find the average value of this, but excluding all entries where number = 0. But I would also like to calculate how many entries there are, including numbers in which number = 0.
Therefore, I canβt just add the numbers WHERE! = 0, as this would give the wrong result in my COUNT.
So I need something like.
AVG(if(numbers!=0)) AS average
Brian
source share