在Oracle中将SQL行转换为逗号分隔的值 [英] Transform SQL Rows into Comma-Separated values in Oracle

查看:79
本文介绍了在Oracle中将SQL行转换为逗号分隔的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何合并多行进入Oracle中以逗号分隔的列表?

Possible Duplicate:
How can I combine multiple rows into a comma-delimited list in Oracle?

如何在不创建函数的情况下从SQL返回行列表中生成逗号分隔的值?需要删除重复项,并删除null或将其值设为"None".

How can you produce a comma-separated values from list of return rows in SQL without creating a function? Need to remove duplicates and null or with 'None' as the value.

示例:select name from student;

结果:

         NAME         
        ------
        Zed
        Charlo
        None
        Charlo
        Dionn
        Ansay

所需的输出:

              Name
             -------
             Zed,Charlo,Dionn,Ansay

推荐答案

http://sqlfiddle.com/#!4 /9ad65/2

select 
  listagg(name, ',') 
    within group (order by id) as list 
from student

这篇关于在Oracle中将SQL行转换为逗号分隔的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆