I need to perform an avg on a column, but I know that most of the values in that column will be zero. Out of all possible rows, only two will probably have positive values. How can I tell mySQL to ignore the zeros and only average the actual values?
相关问题
- What means in Dart static type and why it differs
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
Assuming that you might want to not totally exclude such rows (perhaps they have values in other columns you want to aggregate)
You could probably control that via the WHERE clause:
You can convert zeros to
NULL
, thenAVG()
function will work only with notNULL
values.