0

Can you please help me with the below question with a solution?

I have a table with students' data in as the following:

Name Course Address Email Contact
Venu Gopal N CPA Hyderabad test@gmail.com 999999999
Venu Gopal N CMA Hyderabad test@gmail.com 999999999
Venu N CPA Hyderabad test1@gmail.com 999999988
Venu N EA Hyderabad test1@gmail.com 999999988
Venu N DA Hyderabad test1@gmail.com 999999988

Now I want this table to be displayed as the following:

Name Course Address Email Contact
Venu Gopal N CPA, CMA Hyderabad test@gmail.com 999999999
Venu N CPA, EA, DA Hyderabad test1@gmail.com 999999988

This needs to be done in T-SQL and I have SQL Server 2012 on my system. Can you please provide me with a solution?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Venu
  • 1
  • 1
    this question is [duplicate] (https://stackoverflow.com/questions/46661496/how-to-use-group-concat-function-on-mssql) , you can use group_concat function. – MHA Oct 09 '22 at 08:54
  • 1
    Since SQL includes data definition, a [mcve] for an [SQL question](//meta.stackoverflow.com/q/333952/90527) should include [DDL](//en.wikipedia.org/wiki/Data_definition_language) statements for sample tables (rather than an ad hoc table specification) and [DML](//en.wikipedia.org/wiki/Data_manipulation_language) statements for sample data (rather than a dump or ad hoc format). Desired results don't need to be presented as sample code, as results are the output of code and not code themselves. – outis Oct 09 '22 at 08:58
  • 1
    Does this answer your question? [How to concatenate text from multiple rows into a single text string in SQL Server](/q/194852/90527), "[How to create a SQL Server function to "join" multiple rows from a subquery into a single delimited field?](/q/6899/90527)" – outis Oct 09 '22 at 08:59

0 Answers0