小于8位数的黑斑羚

时间:2018-11-22 03:48:21

标签: sql hadoop impala

我有一些客户编号,其中一些长度超过8位数字。我如何标记它们以便不计入它们?

我尝试了以下操作:

SELECT 
t1.updte_user as staff_number,
(CASE WHEN (CAST(t1.updte_user) AS INT ) Integer not null check 
((CAST(t1.updte_user)AS INT) between 0 and 99999999 THEN  1 else 0 ) end as  
TRUE_STAFF
from old as t1;

我需要更改什么?

2 个答案:

答案 0 :(得分:1)

怎么样?

select staff_number, 
       (case when t1.updte_user > 100000000 then 0 else 1 end)
from old;

如果该值为字符串,则只需使用length()

select staff_number,
       (case when length(t1.updte_user) > 8 then 0 else 1 end)
from old;

答案 1 :(得分:0)

您可以在下面尝试

SELECT 
t1.updte_user as staff_number,
CASE WHEN length((CAST(t1.updte_user AS string))>8 then 0 else 1 as  
TRUE_STAFF
from old as t1;