[Oracle] [36] WM_CONCAT line transfer column

Preface:

There is such a table (product), statistical classification needs to be done

id name on one

type

1 apple 1 fruit
2 pear 2 fruit
3 watermelon 4 fruit
4 book 1 stationery
5 pencil 3 stationery

text:

1, need to be classified according to type

aims:

fruit Apples, pears, watermelon
stationery Book, pencil

Statement:

select type, wm_concat(name) name from product group by type

2, classified by type, and obtains a corresponding number of

aims:

fruit Apple (1), pears (2), watermelon (4)
stationery  Book (1), a pencil (3)

 Statement:

select type, wm_concat(name || '(' || num || ')') name from product group by type

Reference blog:

Oracle wm_concat () function - light rain cold - blog Park
https://www.cnblogs.com/qianyuliang/p/6649983.html

Guess you like

Origin www.cnblogs.com/huashengweilong/p/11361318.html