关于oracle中将一张表中的多条数据的某列查询出来合并为一条数据显示

来源:互联网 发布:hsk网络考试 编辑:程序博客网 时间:2024/04/28 00:51

关于oracle中将一张表中的多条数据的某列查询出来合并为一条数据显示


在ORACLE中可以使用wm_concat(column) 这个函数将指定的列合并为一条数据显示

例如:

SELECT product_id, to_char(wm_concat(return_rate))
  FROM (SELECT id,
               product_id,
               min_amount || '万' || '---' || max_amount || '万' || '   ' ||
               term_value ||
               decode(term_unit, '1', '月', '2', '年', '0', '周') ||
               '   收益:' || return_rate * 100 || '%' AS return_rate
          FROM tnw_pro_annual_return t
         WHERE product_id = 40
         ORDER BY t.id)
 GROUP BY product_id



原创粉丝点击