group_concat with group by in mysql code example

Example 1: group by mysql and concatenate string

mysql> select Id,group_concat(Name SEPARATOR ',') as GroupConcatDemo from GroupConcatenateDemo
   -> group by Id;

Example 2: how to use group_concat in sql server

SELECT STRING_AGG(column_name, ',') AS Result
FROM table_name

Example 3: group_concat mysql

GROUP_CONCAT(expr);

Example 4: group_concat in mysql

GROUP_CONCAT(eng_category_name SEPARATOR ',') as eng_category_name

Example 5: 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

Tags:

Sql Example