2

I have a column that its value is set from enum.

I would like to check if there are lines that mistakely were set to a value nor from the enum, grouped by their value.

The following queries retrive the same results:

Using HAVING

select COLUMN1, COUNT(*) as cntr  
from TABLE1
group by COLUMN1
having COLUMN1 not in ('enum_value_1', 'enum_value_2')  

Using WHERE

select COLUMN1, COUNT(*) as cntr  
from TABLE1  
where COLUMN1 not in ('enum_value_1', 'enum_value_2')
group by COLUMN1  

What should I use?

AngocA
  • 7,545
  • 5
  • 38
  • 52
user3165438
  • 2,541
  • 6
  • 31
  • 51

0 Answers0