长度小于8位的 Impala

kuuvgm7e  于 2021-06-01  发布在  Hadoop
关注(0)|答案(2)|浏览(262)

我有一些客户号码,有些超过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;

我需要改变什么?

ecbunoof

ecbunoof1#

你可以在下面试试

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;
9avjhtql

9avjhtql2#

这个怎么样?

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;

相关问题