Case when RLIKE

82 Views Asked by At

I'm trying to write case when which checks if specific column values are containing certain logic.

    CASE
        WHEN 111 AND ((LENGTH(222) != 10) OR
             (LENGTH(222) = 10 AND NOT ((
             222 RLIKE '[0-9]') OR (222 RLIKE '[a-zA-Z]'))
             OR 222 RLIKE '[^a-zA-Z0-9]' ))
        THEN 1
        ELSE 0

I'm stuck when to assign 1 for values that have length = 10 and only digits or text.

For example '0000000000' has 10 marks and only digits but the logic assigns 0 to it. The aim is to assign for it then '1' value

Any other entries that have 10 marks and only text or integer should be considered as assigned value 1

0

There are 0 best solutions below