更新。
with table1 as
(
select '45 inches' as title from dual
union
select '36 inches' from dual
union
select 'Panasonic TX-40C300B 1080p Full HD LED 40 Inch TV' from dual union
select 'UE40H5000 40" Full HD LED Backlit TV' from dual union
select 'Samsung Series 6 JU6500 Smart 4K Ultra HD Curved LED 40 Inch TV' from dual
)
select case when trimsize <= 42
THEN '42 inches or smaller'
ELSE 'Greater than 42 inches'
end as TV_Type
from(
select case when instr(upper(title),'INCH') > 0 then
trim(substr(title,instr(upper(title),'INCH')-4,3))
when instr(title,'"') > 0 then
trim(substr(title,instr(title,'"')-2,2))
end as trimsize
from table1) tmp1
首先,我決定,如果你輸入的字符串有"
或INCH
關鍵字。基於此,我正在採取先前的價值並修剪它。
注意:如果您有40和英寸之間的額外空間,那麼這是行不通的。另外,如果電視大小是3位數,那麼它可能無法工作。但除此之外,你應該很好。
你的桌子沒有大小的列嗎? – jarlh
是的,但不幸的是,存在相當多的錯誤分類,並且所有條目中的相當大的一部分未被分類。 – Fab
然後我會寫一個查詢來清理數據,然後開始使用你的列。 –