Go Oracle Group Aggregation two notation, Listagg and Wmsys.wm_concat

Source: Internet
Author: User
Tags pears

This article transferred from: http://www.cnblogs.com/ycdx2001/p/3502495.html

WithTempAs(Select‘China' Nation,‘Guangzhou' CityFrom dualUnionAllSelect‘China' Nation,‘Shanghai' CityFrom dualUnionAllSelect‘China' Nation,‘Beijing' CityFrom dualUnionAllSelect‘USA' Nation,‘New York' CityFrom dualUnionAllSelect‘USA' Nation,‘Bostom' CityFrom dualunion allselect  ' 
Select Goodsid,listagg (ss. Storageno,',')  Group (by-Ssg.storageid= bygoodsid  
Select Goodsid,wmsys.wm_concat (ss. Storageno) Storageno from       storagegoods SSG on      ssg.storageid=--  by  Goodsid

The use of the function Wm_concat of the Oracle Merge column

Http://www.jb51.net/article/37604.htm

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
---------------------------------
1.select u_id, Wmsys.wm_concat (goods) Goods_sum 2. 3.from Shopping 4. 5.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
MySQL---group_concat

Go Oracle Group Aggregation two notation, Listagg and Wmsys.wm_concat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.