Oracle Stitching String

Source: Internet
Author: User

Look at the contents of the table you are using first

SELECT * from YHB;

Desired effect

Concatenate strings for the isdropout column of times 1

Isdropout Times

Yes, no, it's 1.

1. Using the Wmsys.wm_concat (EXP1) function

The SQL statements are as follows:

Select Wmsys.wm_concat (a.isdropout) isdropout from YHB a where a.times=1;

Note that when the content in the EXP1 is very long, there will be errors with a string length that is too large, and you need to use a different method as follows

2. Using the Sys.stragg (EXP1) function

Select Sys.stragg (a.isdropout) isdropout from YHB a where a.times=1;

From the results can be seen, Sys.stragg (EXP1) function to get the result of simply splicing the string together, there is no delimiter, so need to process

Select Trim (both ', ' from Sys.stragg (To_char (a.isdropout) | | NVL2 (A.isdropout, ', ', ')) as Isdropout from YHB a where a.times=1;

Where trim is to remove the end of the, number, NVL2 (EXPR1,EXPR2,EXPR3) function functions as follows

Functions: Common functions in Oracle, if the parameter expression EXPR1 value is null, the NVL2 () function returns the value of the parameter expression Expr3, or the NVL2 () function returns the value of the parameter expression expr2 if the parameter expression expr1 value is not null.

Note: Oracle refers to strings with single quotes, such as NVL2 (A.isdropout, ', ', '), and cannot be enclosed in double quotes

Oracle Stitching String

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.