qq_17579189
Caster_Chan
采纳率50%
2015-07-27 01:30 阅读 3.4k

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

图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

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

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

    点赞 1 评论 复制链接分享
  • lzp_lrp 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 评论 复制链接分享
  • lzp_lrp WorldMobile 2015-07-28 00:50

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

    点赞 评论 复制链接分享
  • xiaonan 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 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

    点赞 评论 复制链接分享

相关推荐