Caster_Chan
2015-07-27 01:30
采纳率: 50%
浏览 3.6k

oracle查询,多个字段合拼为一个字段(有图)

图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

5条回答 默认 最新

  • danielinbiti 2015-07-27 01:39
    已采纳

    oracle 的分组字符串合并
    http://www.itpub.net/thread-1702620-1-1.html

    点赞 评论
  • WorldMobile 2015-07-28 00:50

    试试这个

    select id, ltrim(sys_connect_by_path(name, ','), ',') name
    from (select id,
    name,
    row_number() over(partition by id order by name) rn,
    count(*) over(partition by id) cnt
    from table) t
    where rn = cnt
    start with rn = 1
    connect by prior id = id
    and prior rn = rn - 1
    order by id;

    点赞 1 评论
  • WorldMobile 2015-07-28 00:50

    把table换成你的表名,id和name为你表里的字段

    点赞 评论
  • xiaonan 2015-07-29 04:04

    用函数wmsys.wm_concat
    select id, wmsys.wm_concat(name) as names
    from table
    group by id
    order by id

    点赞 评论
  • xiaonan 2015-07-29 04:04

    用函数wmsys.wm_concat
    select id, wmsys.wm_concat(name) as names
    from table
    group by id
    order by id

    点赞 评论

相关推荐 更多相似问题