Answers for "sql group_concat"

SQL
0

how to use group_concat in sql server

SELECT STRING_AGG(column_name, ',') AS Result
FROM table_name
Posted by: Guest on August-27-2020
0

group_concat in mysql

GROUP_CONCAT(eng_category_name SEPARATOR ',') as eng_category_name
Posted by: Guest on February-26-2021
0

group_concat sql server

SELECT emp_id, fname, lname, dept_id, 
GROUP_CONCAT ( strength ) as "strengths" 
FROM employee group by emp_id;
Posted by: Guest on June-20-2021
1

group_concat mysql

GROUP_CONCAT(expr);
Posted by: Guest on January-12-2021
0

group_concat sql server

STRING_AGG ( expression, separator ) [ <order_clause> ]

<order_clause> ::=   
    WITHIN GROUP ( ORDER BY <order_by_expression_list> [ ASC | DESC ] )
    SELECT STRING_AGG(Genre, ',') AS Result
FROM Genres;
Result:

Result                                      
--------------------------------------------
Rock,Jazz,Country,Pop,Blues,Hip Hop,Rap,Punk
Posted by: Guest on March-05-2020
-1

sql server group by concatenate

CREATE TABLE #YourTable ([ID] INT, [Name] CHAR(1), [Value] INT)

INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (1,'A',4)
INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (1,'B',8)
INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (2,'C',9)

SELECT 
  [ID],
  STUFF((
    SELECT ', ' + [Name] + ':' + CAST([Value] AS VARCHAR(MAX)) 
    FROM #YourTable 
    WHERE (ID = Results.ID) 
    FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)')
  ,1,2,'') AS NameValues
FROM #YourTable Results
GROUP BY ID

DROP TABLE #YourTable
Posted by: Guest on October-10-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language