大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说oracle行转列decode_oracle行转列逗号隔开,希望您对编程的造诣更进一步.
第一种
函数 wm_content(‘待转列名称‘) 11g 往后,不推荐使用
实例
多表关联时可以使用
(SELECT wm_concat(nvl(B1.OPERA_CODE,‘a‘)) AS OPERA_CODE FROM OPERATION_NAME B1 WHERE T1.OPERA_REQ_NO=B1.OPERA_REQ_NO) AS SURGERY_OPER_CODE
代码100分
第二种
实例
代码100分WITH TEMP AS
(SELECT ‘CHINA‘ NATION, ‘GUANGZHOU‘ CITY
FROM DUAL
UNION ALL
SELECT ‘CHINA‘ NATION, ‘SHANGHAI‘ CITY
FROM DUAL
UNION ALL
SELECT ‘CHINA‘ NATION, ‘BEIJING‘ CITY
FROM DUAL
UNION ALL
SELECT ‘USA‘ NATION, ‘NEW YORK‘ CITY
FROM DUAL
UNION ALL
SELECT ‘USA‘ NATION, ‘BOSTOM‘ CITY
FROM DUAL
UNION ALL
SELECT ‘JAPAN‘ NATION, ‘TOKYO‘ CITY
FROM DUAL)
SELECT NATION, LISTAGG(CITY, ‘,‘) WITHIN GROUP(ORDER BY CITY) AS CITIES
FROM TEMP
GROUP BY NATION
用法:
LISTAGG(‘待转的列‘,‘分割符号‘) WITHIN GROUP(ORDER BY 列字段) AS XXX 字段 FROM 表 WHERE 条件 group by 分组条件 ;
oracle 行转列,用特殊符号拼接
原文地址:https://www.cnblogs.com/iullor/p/13326538.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/7349.html