listagg wm_concat 行转列】的更多相关文章

一. 这个写法和wm_concat相似,listagg(day,',')要把哪一列转换为同一行within group (order by day)同一行如何排序 with temp as ( ' day from dual union all ' day from dual union all ' day from dual union all ' day from dual union all ' day from dual union all ' day from dual ) selec…
原帖:http://www.cnblogs.com/nayitian/p/3231734.html wmsys.wm_concat Definition: The Oracle PL/SQL WM_CONCAT function is used to aggregate data from a number of rows into a single row, giving a list of data associated with a specific COMMENT_BODY. In ef…
1.通过 10g 所提供的 WMSYS.WM_CONCAT 函数即可以完成 行转列的效果 select group_code, wm_concat(display_title) from DR_OPM_DATASET_RELATED group by group_code 网上看到例子: CREATE TABLE tab_name(ID INTEGER NOT NULL PRIMARY KEY,cName VARCHAR2(20));CREATE TABLE tab_name2(ID INTEG…
工作过程中需要将查询的数据分组并显示在一行.以往的工作经验,在sql server中可以用for xml path来实现. 现提供Oracle数据库的行转列方式 oracle11g官方文档简介如下: LISTAGG Function The LISTAGG function orders data within each group based on the ORDER BY clause and then concatenates the values of the measure colum…
create table demo(id int,name varchar(20),nums int); ---- 创建表insert into demo values(1, '苹果', 1000);insert into demo values(2, '苹果', 2000);insert into demo values(3, '苹果', 4000);insert into demo values(4, '橘子', 5000);insert into demo values(5, '橘子',…
多行转字符串 这个比较简单,用||或concat函数可以实现  SQL Code  12    select concat(id,username) str from app_userselect id||username str from app_user 字符串转多列 实际上就是拆分字符串的问题,可以使用 substr.instr.regexp_substr函数方式 字符串转多行 使用union all函数等方式 wm_concat函数 首先让我们来看看这个神奇的函数wm_concat(列名…
方法一:wmsys.wm_concat(column) 介绍:其函数在Oracle 10g推出,在10g版本中,返回字符串类型,在11g版本中返回clob类型.括号里面的参数是列,而且可以是多个列的集合,也就是说在括号里面可以自由地用‘||’合并字符串.如下面的例子: Select u_id, wmsys.wm_concat(goods || '(' || num || '斤)' ) goods_sum   from shopping   group by u_id 方法二:listagg (c…
在oracle 11g release 2 版本中新增的listagg函数,listagg是一个实现字符串聚合的oracle内建函数;listagg(column,'分隔符') within group (order by column) over(partition by column)分隔符可以为空,order by必选项,可以order by null (1)select status,  listagg(risk_id, ',') within group (order by risk_…
这个比较简单,用||或concat函数可以实现 select concat(id,username) str from app_user select id||username str from app_user 字符串转多列 实际上就是拆分字符串的问题,可以使用 substr.instr.regexp_substr函数方式 字符串转多行 使用union all函数等方式 wm_concat函数 首先让我们来看看这个神奇的函数wm_concat(列名),该函数可以把列值以","号分隔起…
这就是典型的行转列问题. 首先说下最简单的思路  用union all select year,sum(m1) m1,sum(m2) m2,sum(m3) m3,sum(m4) m4 from ( select year,count m1,0 m2,0 m3,0 m4 from atest where month = 1 union all select year,0 m1,count m2,0 m3,0 m4 from atest where month = 2 union all selec…