Oracle-based wm_concat (column) function usage

Source: Internet
Author: User

Oracle wm_concat (column) function in Oracle data, use the wm_concat (column) function, you can merge the selected field data values; 1. merge a single field value, for example: SQL: select t. id, t. name, t. price, t. count, t. uid from goods t; the fields are: id, name, price, quantity, and purchaser Id. query the various commodities purchased by the purchaser. SQL: select t. uid, wm_concat (t. name) from goods t group by t. uid; 2. Merge the combined field values, for example, SQL: select t. id, t. name, t. price, t. count, t. uid from goods t; query the various items purchased by the purchaser and their quantity. SQL: select t. uid, wm_concat (t. name | '(' | t. count | ') goods_num from goods group by t. uid; 3. Define the UDF first and then call the UDF. Pay attention to the parameter example: query the various products purchased by a purchaser. create or replace function CONCAT_NAME (UID VARCHAR2) return VARCHAR2 is comms VARCHAR2 (2000) DEFAULT ''; begin for comm in (select t. name from goods t where t. uid = UID) loop comms: = COMMS | COMM. name | '; end LOOP; return COMMS; end;

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.