数据库

 首页 > 数据库 > MySql > 列转行

列转行

分享到:
【字体:
导读:
         摘要:列转行 ...

列转行

test:

c1   c2

1    a

1     b

2     c

 

select
            to_char(wmsys.wm_concat(c2))                                   ,
            to_char(replace(wmsys.wm_concat(c2),',','/'))

     from
            test   

  group by
             c1

show case:

1     a,b   a/b

2      c       c

同样的功能函数:

 select listagg(c2,',') within group(order by c1)        from test      ;  

列转行
分享到:
SQL_字符操作函数concat函数substr函数 ...
SQL_字符操作函数原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明以下出处,否则追究版权法律责任。 深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/40213181  思维导图: 用简单的例子演示,如下列举,用最简单的操作体会字符操作函数的用法: concat函数 SQL> select ename,job,conc...
SQL之 exists 、in
SQL之 exists 、intips :  1.外表为大表,内表为小表时,使用exist  2.外表为小表,内表为大表时,使用in 示例:外表大,内表小 create table outTable (id1 int); insert into outtable select generate_series(1,1000000); create table inTable (id1 int); insert into inTable values(1),(10000),(100000),(1000000)...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……