wm_concat(column)函实现字段合并
eg: cars
name | car | num |
---|---|---|
zhangsan | audi | 2 |
lisi | benz | 3 |
zhangsan | bmw | 1 |
wangwu | buick | 2 |
wangwu | toyota | 1 |
zhangsan | jeep | 2 |
select name, wmsys.wm_concat(car) from cars group by name
结果:
name | car |
---|---|
zhangsan | audi,bmw,jeep |
lisi | benz |
wangwu | buick,toyota |
select name, wmsys.wm_concat(car || '(' || num || '辆)' ) cars_sum from group by u_id
结果:
name | car |
---|---|
zhangsan | audi(2辆),bmw(1辆),jeep(2辆) |
lisi | benz(3辆) |
wangwu | buick(2辆),toyota(1辆) |