Questions tagged [string-aggregation]

This tag is intended for SQL questions where multiple string (character) values should be aggregated into a single value using GROUP BY. The equivalent of sum() - just for strings.

The ISO/IEC SQL standard function for this is LISTAGG, but several DBMS:es have their own string aggregation functions:

386 questions
2
votes
2 answers

String formatting using LISTAGG in Oracle. Escaping single quote ` ' `

How can I format the output of listagg in Oracle to produce output(every field in the single quote) as 'student1', 'student2', 'student3'. I have gone through documentation and other question on listagg but can't find much. SQL Query to concatenate…
krishnakant
  • 355
  • 1
  • 4
  • 17
2
votes
1 answer

I want to do group_concat in SQL Server

I know group_concat doesn't work in SQL Server 2008, but I want to do group_concat. My sample data looks like this: email address | product code ----------------------+--------------- garry123@gmail.com | A123A garry123@gmail.com …
c_174
  • 51
  • 2
  • 7
2
votes
3 answers

How to put result of one column inside a string variable?

I try to select number of rows and then put them into string variable such as 1,2,3,4,5, but get this error : Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used…
hmahdavi
  • 2,250
  • 3
  • 38
  • 90
2
votes
1 answer

How to concatenate multiple rows order by sequence in Oracle10g

If I have a data like this: GROUP | SEQUENCE | COMMAND ------------------------------ ONE | 3 | MESSAGE ONE | 1 | ONE | 2 | …
jitd
  • 45
  • 1
  • 10
2
votes
2 answers

WM_CONCAT duplicates removal

I have a table like below. colA colB 12345 NHS,CDE,BCD 12345 NHS,ABC,DEF Need to display the data in below format colA colB 12345 NHS,ABC,BCD,CDE,DEF I need generalized solution to remove the duplicate…
Raghava Ch
  • 77
  • 2
  • 10
2
votes
2 answers

Comma separated column without XML path

I have table like below ID Name 1 a 1 b 1 c 2 d 2 e 3 f I would like to get result as ID Name 1 a,b,c 2 d,e 3 f I don't want to use any XMLPATH or coalesce functions. Just in simple SQL query I need to get the expected result.
user1912935
  • 361
  • 4
  • 13
  • 34
2
votes
2 answers

I need result from select statement as multiple data of birth for a single id

APPLICANT_ID DATE_OF_BIRTH 206209579 04/29/82 206209579 04/29/82 203276426 06/01/69 203276426 02/03/96 203276426 06/02/99 I need result as 206209579 04/29/82,04/29/82 203276426 …
Anand Yadav
  • 65
  • 1
  • 2
  • 7
2
votes
5 answers

string aggregation in Oracle 10g

How to aggregate string( concatenate) with Oracle 10g SQL?
acroa
  • 3,239
  • 4
  • 17
  • 6
2
votes
1 answer

Concatenating fields when BREAK ON command is used

I have built a command that uses the BREAK ON command to stop the output of duplicate field names. For example: f.name | f.value f.name | f.value f.name | f.value becomes: f.name | f.value | f.value | f.value Is there any way to have…
Sonic-Boom
  • 21
  • 1
2
votes
3 answers

How to get the grouping output in PLSQL

I am having two tables: table1 : test1 desc test1 empcode number(6) qualification_code number(2) table2 :test2 desc test2 qualification_code number(2) qualification_name varchar2(10) select * from test1 120633 10 120633 20 120633 30 select…
user2001117
  • 3,727
  • 1
  • 18
  • 18
2
votes
2 answers

Group_concat MySQL function's equivalent in Oracle

Hi i am looking for a function same group_concat of mysql in oracle or some functionality
maxjackie
  • 22,386
  • 6
  • 29
  • 37
1
vote
3 answers

How to write a query that does something similar to MySQL's GROUP_CONCAT in Oracle?

When I run the following SQL query in my Oracle database: SELECT p.pkt_nazwa, u.us_nazwa FROM punkty p, kategorie_uslug ku, usluga u WHERE ku.pkt_id = p.pktk_1_id AND ku.us_id = u.usk_1_id ORDER BY p.pkt_nazwa;…
makbol
  • 310
  • 2
  • 12
1
vote
1 answer

How do I group by values, but only when they're consecutive?

I have the following table: ID Number Size 7 1 1.5 7 2 1.5 8 1 1.625 8 2 1.03125 8 3 1.03125 8 4 1.03125 8 5 1.625 8 6 1 8 7 1.625 8 8 1.625 8 9 1.625 9 1 1 9 2 2 9 3 3 9 4 4 9 5 1 I would like to create a…
1
vote
2 answers

Data Preparation for Market Basket Analysis using Apriori Algorith using R

I am planning to run apriori algorithm on a dataset to find association among product purchase. The dataset looks like this order_id <- c('AG-2011-2040','IN-2011-47883',…
1
vote
1 answer

SQL Server 2019 - Ordering in sub select

In my database I have a Tracking Codes table as a child of a single Employment table. Along with other data, I am trying to return all of the Tracking Codes in a comma separated string so there will only be one row per Employment. However, I want…
Penx
  • 35
  • 4