Imagine this table:
id col1 col2 col3 col4
1 A A C
2 B B B
3 D D
I would like to add a column that tells me if all not-null values of the row match.
So the ideal output is:
id col1 col2 col3 col4 is_a_match
1 A A C FALSE
2 B B B TRUE
3 D D TRUE
I have tried:
select *,
case
when col1 = col2
and col2 = col3
and col3 = col4
then 'TRUE'
else 'FALSE'
end as is_a_match
from my_table
But would return false for all due to the null values.
What is the best way to achieve the output above?