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
-1
votes
1 answer

Selecting with LEFT OUTER JOIN and return as comma-separated list

On MS SQL Server 2008, how do I make a select statement, that joins two tables, and return the content of table 2 as a comma-separated list? Example: Table 1 contains all my orders, and table 2 my order lines. I want to select all fields from…
Ploughansen
  • 303
  • 1
  • 5
  • 14
-1
votes
1 answer

How to use Oracle to query row column A value as input on second row column B and loop all relation records

In oracle Query either pure SQL or PLSQL, is that possible with the given source table to have the expected result? Thanks Source Table: Col_Old_ID Col_New_ID ID_1 ID_2 ID_2 ID_3 ID_A ID_B ID_B ID_C ID_3 ID_4 ID_4…
Lee Jack
  • 3
  • 2
-1
votes
1 answer

Universal/Dynamic SQL function to take any table and concatenate values to strings?

Trying to take existing solutions and abstract it so I dont have to rewrite code each time. I imagine this must exist already but I only been able to find custom implementations. Picturing fn_tableToConcatStrings( tbl Table)
Vinh Ton
  • 107
  • 3
  • 10
-1
votes
1 answer

All Id into a single column

select ProductId from Products I am getting the output as follows: ProductId 1 2 3 4 I want to get output as like follow: ProductID 1,2,3,4
Biddut
  • 418
  • 1
  • 6
  • 17
-1
votes
3 answers

How To use generate row number with group by option

The Input table DEDUPE SOURCE Legacy_vendor Vendor Condition application Condition type Doc type MX_PRISMA_PDN 9215217 1012473 EF ZNE1 ZMRO MX_PRISMA_PDN 9215217 1012473 EF ZNE1 …
Balaranga
  • 1
  • 1
-1
votes
3 answers

Concat the second column value if the first column value is same

I have a query like below and listed output of it: SELECT DISTINCT TRACKING_NUM,TITLE_OF_DOC_SEC FROM some_table WHERE TRACKING_NUM IS NOT NULL; o/p: TRACKING_NUM TITLE_OF_DOC_SEC 007 Email Flow 007 Test Bug 53306 007 …
roshanK
  • 409
  • 4
  • 10
  • 19
-1
votes
4 answers

Merging Query Result into single row - Oracle

Can I do like this in oracle,.? I have some data like this: No | Data | =========== 1 | A | 1 | B | 1 | C | 1 | D | Is there any query that can produce a result like this,.? No | Data | ================= 1 | A, B, C, D…
Praditha
  • 1,162
  • 5
  • 24
  • 45
-2
votes
1 answer

How to list comma-seperated values of a given out from SQL program

To know doctors who have done 15 or more episodes from tables: Table 1 and I have written this code: select d.DoctorName from tblDoctor d, tblEpisode e where e.DoctorId = d.DoctorId group by d.DoctorId, d.doctorname having …
Heer
  • 15
  • 6
-2
votes
3 answers

Build a report with SQL with combining columns and rows?

Here is my table: Table Purchase…
KojTug
  • 351
  • 1
  • 8
-2
votes
2 answers

nesting and unnesting

I have a table like below name value ----- | ------ rami | 2 rami | 3 rami | 4 sam 5 sam 6 I want to piviot it in a way to get this result Rami …
-2
votes
1 answer

Concatenate strings in a column in PostgreSQL

I am trying to transform the table below: id another_id_1 another_id_2 remarks 1 34. 151. good 2. 34. 151. okay 3. 34. 152. bad 4. 34. 153. very good 5. 34 153 …
-2
votes
1 answer

Display column values rowwise in sql

Can we have the column values displayed rowwise separated by commas. For example, the below returns a column. Can we make the expected output happen select [name] as database_name from sys.databases Actual output database_name db1 db2 db3 Expected…
-2
votes
1 answer

Turning SQL table column into sentence structure

I need to be able to take a column from a SQL table and write a query that will output this in a sentence format. example column A --------- Abraham Jones Henry Walter output would look like this Abraham, Jones, Henry, Walter
-2
votes
1 answer

Concatenate multiple rows to one row

I have the below data and I have to concatenate the long text column and make it as a single row. The challenge part is only one row has the notification number and other rows are null. You cannot group by the notification number. I need the output…
Peak
  • 21
  • 1
  • 5
-2
votes
2 answers

GROUP_CONCAT() eqivalent in postgres

In MySQL I use GROUP_CONCAT() function, nevertheless now i need to convert that to Postgres. Can anyone help me out how to convert such query into Postgres? I think the only one which has to be replaced is the line with GROUP_CONCAT? SET @sql =…
Henry
  • 537
  • 1
  • 9
  • 22
1 2 3
25
26