Questions tagged [sql-server-group-concat]

In MySQL GROUP_CONCAT functionality is comma separated values grouped by a defined key.

In MySQL GROUP_CONCAT functionality is comma separated values grouped by a defined key.

62 questions
3
votes
3 answers

Multiple rows to one comma-separated value different ID

This question already has an answer here: Multiple rows to one comma-separated value [duplicate] 1 Answer I want to create a table valued function in SQL Server, which I want to return data in comma separated values. For example table: tbl ID |…
Stfvns
  • 1,001
  • 5
  • 16
  • 42
3
votes
1 answer

Concatenate one field after GROUP BY

This question have been asked many times in SO but none of the answers is satisfying to my situation. Question 1 Question 2 Question 3 Question 4 I am dealing with a DataObjectVersions table that contains multiple versions for around 1.2 million…
2
votes
1 answer

Concatenate values that are grouped by a column

I have the following table: Code Ref Value A1 Car A A1 Car - A1 Car B B2 Truck CC B2 Truck D B2 Truck - C3 Van E C3 Van F C3 Van - C3 Van G The goal I am…
Volearix
  • 1,573
  • 3
  • 23
  • 49
2
votes
3 answers

TSQL: How to Join / Combine rows of a single column into a CSV list

I have a table called "colamer" as shown below: ID Title SectionID 1 abc 231 2 abc 232 3 pqr 95 4 jkl 165 My Stored Procedure: CREATE PROCEDURE CheckDuplicateBannerforSection /* …
user3239820
2
votes
1 answer

How can I concatenate strings in a GROUP BY clause without a subquery in SQL Server without an additional query?

I'm looking for the equivalent of a GROUP_CONCAT() MySQL function in SQL Server 2012 - THAT DOES NOT USE A SUBQUERY, explained below: CREATE TABLE Temp ( ID INT PRIMARY KEY NOT NULL IDENTITY(1,1), ColA varchar(900) NULL, ColB varchar(900)…
Ehryk
  • 1,930
  • 2
  • 27
  • 47
1
vote
1 answer

SQL CONCAT IF Statement?

Morning All, Im not to sure how i need to solve my following query... I have the following query which pulls back the desired records in SQL server... SELECT agenda.AgendaItemNumber,Agenda.AgendaName, AgendaType.AgendaTypeDescription,…
Betty
  • 621
  • 1
  • 12
  • 24
1
vote
1 answer

mixing of pattern matching and date time functions in mysql

I have problem mixing pattern match and curdate() function. Below is the table structure, where some of the fields current date is updated everyday. I am not sure whether they can be mixed.Please help me sort this out. Thanks. ta1 ta2 …
1
vote
2 answers

SQL Server Have a select query as part of one select columns

Hey Im just wondering if the following is possible select id, name, (select name from secondTable where companyId = tableOne.id) as concatenatedString.. from tableOne so what I am looking for the select to do is for each record return in tableOne,…
StevieB
  • 6,263
  • 38
  • 108
  • 193
1
vote
2 answers

In SQL, create pairs based on a grouping and count their frequency

What I want is to create DISTINCT pairs of column 2 for each ID and arrange them by count. Let's use this table as an example: CREATE TABLE mytable (`ID` int, `C2` varchar(1), `C3` varchar(2)) ; INSERT INTO mytable (`ID`, `C2`,…
1
vote
1 answer
1
vote
2 answers

Using STUFF with DATE

I am trying to use the STUFF functionality in SQL Server 2016 to select DATE information and return it to a table. Occasionally there are multiple dates to return. I have already used STUFF to get other data I need. Email = STUFF((SELECT ', ' +…
1
vote
1 answer

Group_Concat in pairs of nth

I have a query that I normally group_concat. I need to know if dbo.group_concat has the ability to pair the result of a query into pairs of 3 (as an example). For example: select size, pattern, dbo.group_concat(mass) mass from labels group by…
1
vote
3 answers

Group and concatenate many rows to one

I want to "concatenate" all the "Text"-rows into one single row and get one row as a result. Is this even possible? I use MSSQL Server 2005.
f00860
  • 3,486
  • 7
  • 41
  • 59
1
vote
2 answers

Concatenate multiple rows

I'm using Microsoft SQL Server 2005. I think I need a sub-query. I'm looking for one (1) row per customer, with the AvailableAction field be a concatenation of all the Actions for each customer. use tempdb GO IF DB_ID('myDatabase') IS NOT NULL …
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
1
vote
2 answers

How to concatenate multiple rows?

I have the following query which returns the salary of all employees. This work perfectly but I need to collect extra data that I will aggregate into one cell (see Result Set 2). How can I aggregate data into a comma separated list? A little bit…
Martin
  • 39,309
  • 62
  • 192
  • 278