`
raozhiyong11
  • 浏览: 135521 次
  • 性别: Icon_minigender_1
  • 来自: 江西
社区版块
存档分类
最新评论

oracle 多行转一列,一列转多行

 
阅读更多

有一个表,表名为tab_test,如下:



一、多行转一列
select id, vnum, to_char(wmsys.wm_concat(vname)) c
from tab_test group by id,vnum;
执行上述sql后,如下:


 

二、一列转多行
with a as (select '/ABC/AA/AD/ABD/JI/CC/ALSKD/ALDKDJ' id from dual)
select regexp_substr(id,'[^/]+',1,rownum) id from a
connect by rownum <= length(regexp_replace(id,'[^/]+'))
执行上述sql后如下:


 

 

本文转载自:http://blog.163.com/fushahui_1988@126/blog/static/82879994201192844355174/

  • 大小: 25 KB
  • 大小: 25.2 KB
  • 大小: 33.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics