Reputation: 10954
I would like to check that two columns in my Hive table with the same type always have the same values (potentially for a subset).
Someone asked a similar question previously, but I do not think that it was conclusively answered there. I am basically looking for a sum(col == col2)
type semantics.
Upvotes: 1
Views: 572
Reputation: 38290
select sum(case when !(col1=col2 ) then 1 else 0 end) as sum_not_equal
from
(select 20 col1, 20 col2
union all
select 10 col1, 10 col2
)s
or
count(case when !(col1=col2 ) then 1 end)
Upvotes: 1