Home > database >  No cursor, with simple SQL merge the results
No cursor, with simple SQL merge the results

Time:10-01

The create table temp01
(
A varchar (20),
B varchar (20)
);
Insert into temp01 values (' aa ', '12 | | 1');
Insert into temp01 values (' aa ', '13 | | 4');
Insert into temp01 values (' aa ', '3 | | 66');
Insert into temp01 values (' aa ', '4234 | | 88');
Insert into temp01 values (' aa ', '30 | |' 33);

Need to get the result:
12 | | 1, 13 | | 4, 3 | | 66423 | | 88, 30 | | 33
Just a simple query how can you do it? thank you

CodePudding user response:

Find a way, using listagg function, sweat ~

The select listagg (b, ', ') within GROUP (order by a) from the test GROUP by a;

CodePudding user response:

Encourage that.

CodePudding user response:

Used WMSYS. WM_CONCAT
11 g, please start using listagg

Saying the listagg within group behind () () seems to be fixed writing, why do so many keyword is not the default, don't know what is design

CodePudding user response:

reference Diza1986 reply: 3/f
used WMSYS. WM_CONCAT
11 g, please start using listagg

Saying the listagg within group behind () () seems to be fixed writing, why do so many keyword is not the default, don't know is how to design


From the literal can understand, this is the order of the group,

String concatenation and summary Numbers, collect value, who are put first who has no effect on the result, but the string concatenation, to specify who before, and who in the back;

CodePudding user response:

12 c WMSYS. WM_CONCAT does not support this

CodePudding user response:

reference 4 floor wmxcn2000 response:
Quote: reference Diza1986 reply: 3/f

Used WMSYS. WM_CONCAT
11 g, please start using listagg

Saying the listagg within group behind () () seems to be fixed writing, why do so many keyword is not the default, don't know is how to design


From the literal can understand, this is the order of the group,

String concatenation and summary Numbers, collect value, who are put first who has no effect on the result, but the string concatenation, to specify who before, and who in the back;


Yes, the grammar patchwork sequence must be specified, as far as I am concerned, the contact when this function is a bit awkward feeling
1, listagg this name is a bit less intuitive, may is my English is not good
2, the within group (order by XXX) must be fixed syntax is a bit long, is itself a analysis function can be used, with over limit over the order by must not have
3, why must specify order by, if real business does not require the order why reinvent the wheel, like WM_CONCAT isn't quite good, after all sorts of performance cost is very high

CodePudding user response:

refer to 6th floor Diza1986 response:
Quote: refer to 4th floor wmxcn2000 response:

Quote: refer to the third floor Diza1986 response:

Used WMSYS. WM_CONCAT
11 g, please start using listagg

Saying the listagg within group behind () () seems to be fixed writing, why do so many keyword is not the default, don't know is how to design


From the literal can understand, this is the order of the group,

String concatenation and summary Numbers, collect value, who are put first who has no effect on the result, but the string concatenation, to specify who before, and who in the back;


Yes, the grammar patchwork sequence must be specified, as far as I am concerned, the contact when this function is a bit awkward feeling
1, listagg this name is a bit less intuitive, may is my English is not good
2, the within group (order by XXX) must be fixed syntax is a bit long, is itself a analysis function can be used, with over limit over the order by must not have
3, why must specify order by, if real business does not require the order why reinvent the wheel, like WM_CONCAT isn't quite good, after all sorts of performance cost high


4. Moreover, he also does not support distinct, did you sort to repeat is still very difficult,,?

CodePudding user response:

Name: no problem, the List of Aggregate short;

With over to limit of oder by the substandard, can look at the official documentation, for the specific explanation;

Began to 12 c does not support wm_concat actually oracle's website also never admit the function, if the business requirements, make the performance of the sort used wm_concat is not optimistic, more bloated statements,

CodePudding user response:

Software is written by a foreigner, nature is that they are the rules, I follow you went, habit good,

CodePudding user response:

refer to the eighth floor wmxcn2000 response:
name no problem, the List of Aggregate short;

With over to limit of oder by the substandard, can look at the official documentation, for the specific explanation;

Began to 12 c does not support wm_concat actually oracle's website also never admit the function, if the business requirements, make the performance of the sort used wm_concat is not optimistic, statement more bloated,


Wm_concat performance is very bad, anyway,
By the standards of the family of products have to follow somebody else ah, yes, yes
  • Related