我有一个表product,列product id为字符串数据类型,如下所示。
Product_id
101
102
102a
我想知道是否有任何方法可以在product_id中获取所有值,这些值不能满足102a值的整数条件,因为它不能转换为整数
查询类似
的内容select product_id from product where product_id <> integer
输出应为
Product_id |
---|
In snowflake:
select column1 as Product_id
from values
('101'),
('102'),
('102a')
where try_to_number(Product_id) is null;
为
PRODUCT_ID |
---|
你可以像这样使用正则表达式:
SELECT Product_id
FROM product
WHERE Product_id !~ 'D';
这将只返回具有Product_id
值的记录,而不具有任何非数字字符(即它确实具有的字符都是数字)。