I am trying to work out the SQL to average a series of numbers, but only to include those greater than 0.
For example:
Field
4
5
0
6
SELECT Avg(Field) FROM Table;
gives 3.75. But I want it to ignore the 0 so the average is 5.
SELECT Avg(Field) FROM Table where Field > 0;
works but what if I have more than 1 field:
Field1 Field2
4 2
5 0
0 3
6 4
SELECT Avg(Field1), Avg(Field2) FROM Table;
Using
SELECT Avg(Field1), Avg(Field2) FROM Table where Field1 >0 and Field2>0;
will not work
How do I do that? Note the numbers can be anything from 0 to 100