oracle 行列转换
来源:互联网 发布:c语言字符串比较大小 编辑:程序博客网 时间:2024/05/16 22:31
oracle 行列转换 (http://blog.163.com/xiao_maomao_chong/blog/static/3168623920086445319803/)
笔试 2008-07-04 16:53:19 阅读118 评论0 字号:大中小
有一个字符串
,1,2,5,9,1,2,5,9,1,3,9,
通过SQL文将以上字符串处理后得到如下查询结果:
col
1
2
5
9
1
2
5
9
1
3
9
with tbl2 as (
select ',1,2,5,9,1,2,5,9,1,3,9,22,25,10,155555,' as temp from dual
)
select substr(temp,currentIndex,nextIndex-currentIndex) as cols from
(
select temp
,level lv
,instr(temp,',',instr(temp,','),level)+1 as currentIndex
,instr(temp,',',instr(temp,','),level+1) as nextIndex from
(
select temp
,length(temp)- length(replace(temp,','))-1 rowcnt
from tbl2
) a
connect by level <= rowcnt
)
挑战无处不在~~
with tbl2 as (
select ',1,2,5,9,1,2,5,9,1,3,9,' as temp from dual
)
select substr(temp2,lv,1) from
(
select temp2,level lv from
(
select temp,replace(temp,',') temp2,length(replace(temp,',')) rowcnt from tbl2
) a
connect by level <= rowcnt
)
select DECODE('A', '01' ,'WO JIAO DDDD', 'EEEE' , '02', '55' )
AS LIU from
(
select
SUBSTR(mid,1,2) as a,
SUBSTR(mid,4,2) as b,
SUBSTR(mid,7,2) as c,
SUBSTR(mid,10,2) as d,
SUBSTR(mid,13,2) as e
from liu )
**********************************************************************************
select DECODE(a, '01' ,b, '02' , c, d )
AS LIU from
(
select
SUBSTR(mid,1,2) as a,
SUBSTR(mid,4,2) as b,
SUBSTR(mid,7,2) as c,
SUBSTR(mid,10,2) as d,
SUBSTR(mid,13,2) as e
from liu )
with tbl2 as (
select wmsys.wm_concat(mid) as temp from liu
)
select substr(temp,currentIndex,nextIndex-currentIndex) as cols from
(
select temp
,level lv
,instr(temp,',',instr(temp,','),level)-2 as currentIndex
,instr(temp,',',instr(temp,','),level) as nextIndex from
(
select temp
,length(replace(temp,','))/2 rowcnt
from tbl2
) a
connect by level <= rowcnt
)
- ORACLE行列转换实例
- oracle 行列转换
- 行列转换 oracle
- ORACLE DB行列转换
- oracle行列转换总结
- oracle 行列转换
- 关于oracle行列转换
- oracle 实现行列转换
- oracle行列转换总结
- Oracle 行列转换 总结
- oracle行列转换总结
- oracle行列转换
- oracle 行列转换
- oracle 行列转换
- oracle 行列转换
- oracle 行列转换
- Oracle 行列转换 总结
- Oracle 行列转换
- sizeof
- C# SendMessage
- 传参 容器
- displaytag分页导航的国际化
- C#实现所有经典的排序算法
- oracle 行列转换
- 获取信息的有关Windows API
- linux多线程编程
- C#生成基于COM的DLL供VB调用
- mysql的create database
- C#仿QQ皮肤-实现原理系列文章导航
- Flex中为控件使用远程XML数据
- SQL排序规则应用小记
- The Advantages and Disadvantages of the Mbt Shoe