I would like to know whether I can test some value against a condition in each returned row somehow in the query?
e.g.:
I have columns:
X Y Z
-1 1 2
2 2 -1
3 -1 3
I want to use avg() for all values except for -1. I CANNOT use where<> -1 as each row contains it once.
Use WHERE to filter away the values you don’t want to include in your average, for example to include all numbers in the average except for -1:
Note that if you really want to include all numbers except -1 as you said in your question then you should change the WHERE clause to
x <> -1but I doubt that this is what you want.