有一张表A格式为id code price
1 100,101, 50
2 102,103, 20
3 104, 30我现在想要
id code price
1 100 50
1 101 50
2 102 20
2 103 20
3 104 30谢谢!
1 100,101, 50
2 102,103, 20
3 104, 30我现在想要
id code price
1 100 50
1 101 50
2 102 20
2 103 20
3 104 30谢谢!
解决方案 »
- resp := Utl_Http.Get_Response ( r => req )总是异常
- 谁有Oracle OLeDB驱动的下载地址
- Oracle 角色里面有没有类似Sql Server里面的 dbOwner
- 请教 获取当前用户可以操作的数据库名称列表?
- 本人刚学oracle 不明白为什么同时需要存储过程和函数啊?感觉存储过程完全可以替代函数啊? 勿喷啊,高手给点意见看看
- oracle procedure 实际开发遇到的问题
- 请问如何在oracle数据库的查询结果集中增加"序号"这样的虚列?
- 问个sql语句
- oracle装不上
- 请教oracle重装问题,50分,解决立刻给。
- oracle的procedure怎么返回状态值
- win7 64 Visual Studio 2008 用oledb连接不到数据库
列转行:
列:code列,以逗号分隔有两个部分, 要转成两行,每行的code值都是逗号间的值。
with t as (
select 1 id, '100,101,' code, 50 price from dual union
select 2, '102,103,', 20 from dual union
select 3, '104,', 30 from dual
)
select t.id,rtrim(regexp_substr(code,'[0-9]+,',1,rn),',') code2
from t,(select rownum rn from dual connect by level < 100) r
where regexp_substr(code,'[0-9]+,',1,rn) is not null
order by t.id,code2
-- 其中level < 100这里的100是取你code字段的最大分割次数,如果超出100你可以把这个值上调。
with t as (
select 1 id, '100,101,' code, 50 price from dual union
select 2, '102,103,', 20 from dual union
select 3, '104,', 30 from dual
)
select t.id,regexp_substr(code,'[^,]+',1,l)
from t,(select level l from dual connect by level < 10) r --这里的10表示最多有10-1=9个逗号分隔。如果不过自行改正。
where length(code)-length(replace(code,',',''))+1>r.l
order by t.id,1;