I have a SQL query containing (among others) ten fields, call them v1, ..., v10, which I would like to test. The expected situation is that most are NULL and the remaining values are all equal. The interesting (error?) case I’m searching for is when there are at least two non-NULL values which are unequal.
Is there some better way to do this than
v1 != v2 or v1 != v3 or ... v8 != v9 or v8 != v10 or v9 != v10
with binomial(10, 2) = 45 conditions in total?
Aside from being inelegant it seems brittle —and having just debugged an issue where one variable in a long list had a typo, not merely an academic concern. But if that’s the only way it’s doable... though if the list expands to 20 it’s much less nice.