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

Incorrect syntax near 'FOR'

Following code is not working - SELECT [LY-1], LY = STUFF((SELECT ',' + name FROM temp1 FOR XML PATH ('')), 1, 1, '' ) FROM temp1 GROUP BY [LY-1]; As it is giving below error- Msg 103010, Level 16, State 1, Line 73 Parse error at…
Sim
  • 13
  • 2
  • 4
-2
votes
1 answer

How to concatenate text from multiple rows into a single text string in Oracle server?

I have a table with data like this: ID, END_DATE, CLOSE_DATE 1, 2018-05-18, 2018-05-15 2, 2018-05-18, 2018-05-14 3, 2018-05-18, 2018-05-11 4, 2018-05-18, 2018-05-10 I need the output when i query in Oracle server END_DATE CLOSE_DATE…
Vasanth
  • 75
  • 8
-2
votes
1 answer

How to select multiple values against single record in a column in postgresql

I have two tables with many to many relation. table 1: Code | Product | ------------+----------+ 00001 | product1 | 00002 | product2 | table 2: Tag_id | name | -------+-------- 1 | tag1 | 2 | tag2 |…
M Tahir Noor
  • 443
  • 2
  • 10
  • 31
-2
votes
1 answer

What is the modern analogue for a two-dimensional string array?

I'm refactoring some legacy code that uses a 2D string array: /// Array of valid server messages private static string[,] serverRsp = { {"JOIN", "RSP" }, {"SETTING", "RSP" }, . . . I want to modernize…
-3
votes
1 answer

SQL Server STRING_AGG() : equivalent in Linq

This is my table tbl_emp: This is the result I need: In SQL Server 2017, I can use STRING_AGG to get the desired result: SELECT name, STRING_AGG(email,'') 'email', STRING_AGG(email2,'') 'email2' FROM tbl_emp GROUP BY name How…
-3
votes
1 answer

Combining strings by different type in SQL PSQL or SQL server

How to combine strings by different type in Mysql, PostgreSQL or SQL Server, below data type = 1 is province and type = 2 is city, I would like to combine them to a column, name code type Sichuan 610000 1 Chengdu …
Elsa
  • 1
  • 1
  • 8
  • 27
-3
votes
1 answer

How to get grouping of rows in SQL

I have a table like this: id name 1 washing 1 cooking 1 cleaning 2 washing 2 cooking 3 cleaning and I would like to have a following grouping id name count 1 washing,cooking,cleaning 3 2 washing,cooking …
-3
votes
3 answers

sql multiple column concatenation using stuff

i have two columns invoice status and vendor number.i want to concatenate invoice status into one row based on vendor number using stuff vendor num invoice status 70000141 V-Parked Items 70000141 V-Parked Items 70000141 not…
-3
votes
1 answer

Oracle Query to get data

Please help to how to write the Oracle query to get the result (in 3 seperate columns) like "abcd 1,5,7 xyz" from below table,I want to include COL3 as a seprate column. Please help Oracle Database table ====================== col1 | …
-4
votes
1 answer

I want the output without using the case or decode in Oracle 10g

STUD_ID SUBJECT GRADE 1 math a 1 english b 1 computer c 2 math c 2 lang a 3 phys a 3 chem …
Sam
  • 1
-4
votes
1 answer

Java - Input string into array

I have a text file like this : testcaseZ : a, b, c testcaseX : b,d testcaseC : b I want to have a string array like : abcd testcaseZ 1 1 1 0 testcaseX 0 1 0 1 testcaseC 0 1 0 0
if412001
  • 1
  • 4
1 2 3
25
26