有一个品名字段,存的数据以英文逗号分隔,数量单位字段以分号分隔,以品名为参考,将多品名的一行数据拆分成为多行显示。oracle数据库。
综合广大网友和实际情况,记录下sql语句如下:
select t.*,
regexp_substr(t.gdesc, ‘[^,]+’, 1, n) strgdesc,
regexp_substr(t.quantity, ‘[^;]+’, 1, n) strquantity
from tm_pcustom_summary t,
(select level n from dual connect by level <= 10)
where regexp_substr(t.gdesc, ‘[^,]+’, 1, n) is not null;