我正在使用 INSTR 搜索字符串中的子字符串(在特定位置)。但是,如果似乎没有正确搜索。我确认 part_no 列是 STRING 类型。
代码如下:
select part_no,
case
when instr(part_no, '1', 4,1) = 4 then 'Con'
when instr(part_no, '2', 4,1) = 4 then 'Pairs'
when instr(part_no, '3', 4,1) = 4 then 'Tri'
end as Part_Type
from INV_PART
结果如下:
PART_NO PART_TYPE
26010U180700710
2V010U080250416
2V010U080310H00
7P022U161557700
80110M060300790 Conductor
想知道为什么它不对其他部分进行分类,即第一个三个应该是'Con'而第四个应该是'Pairs'?
不胜感激任何输入。
谢谢。