天天看点

oracle 关键字 wm_concat 将多条数据合并成一条

用Oracle自带的wm_concat函数即可实现这样的拼接功能,默认拼好以逗号分隔: 

Sql代码  

oracle 关键字 wm_concat 将多条数据合并成一条
  1. select t.col1,  
  2.        t.col2,  
  3.        wm_concat(t.col3) col3,  
  4.        wm_concat(t.col4) col4,  
  5.        wm_concat(t.col5) col5,  
  6.        wm_concat(col6) col6  
  7.   from t_table t  
  8.  group by t.col1, t.col2  

别忘了后面的group by没用聚合函数的字段col1,col2 

oracle 关键字 wm_concat 将多条数据合并成一条