In an Oracle database, you can use the Wm_concat (column) function to merge fields, and the following is a detailed introduction to the implementation of this feature for your reference.
The Oracle Wm_concat (column) function allows us to use it frequently, and below teaches you how to use the Oracle Wm_concat (column) function to implement a field merge if you have an Oracle Wm_concat (column) If you are interested in the use of functions, you may wish to take a look.
Shopping:
-----------------------------------------
U_ID Goods num
------------------------------------------
1 Apples 2
2 Pear 5
1 Watermelon 4
3 Grapes 1
3 Banana 1
1 Oranges 3
=======================
The desired result is:
--------------------------------
u_id Goods_sum
____________________
1 apples, watermelon, oranges
2 Pears
3 Grapes, Banana
---------------------------------
- Select u_id, Wmsys.wm_concat (goods) goods_sum
- From shopping
- GROUP BY u_id
Desired result 2:
--------------------------------
u_id Goods_sum
____________________
1 apples (2 kg), watermelon (4 kg), Orange (3 kg)
2 pears (5 kg)
3 grapes (1 kg), banana (1 kg)
---------------------------------
Using the Oracle Wm_concat (column) function:
- Select u_id, wmsys.wm_concat (Goods | | ' (' | | | num | | ' kg ') goods_sum
- From shopping
- GROUP BY u_id
Use of Oracle Wm_concat (column) functions